Project

General

Profile

Actions

Backport #3629

closed

expand_path doesn't expand "~a"

Added by tmat (Tomas Matousek) about 12 years ago. Updated almost 11 years ago.

Status:
Closed
Priority:
Normal
[ruby-core:31536]

Description

=begin
ENV["HOME"] = 'C:/xxx'
Dir.chdir 'C:/temp' do
p File.expand_path("a")
p File.expand_path("~/a")
p File.expand_path("~a")
end

Prints:

"C:/temp/a"
"C:/xxx/a"
"~a"

I'd expect it to print:
"C:/temp/a"
"C:/xxx/a"
"c:/temp/~a"

"~a" should be considered a regular file name and as such should be prefixed with the current directory path like any other file name.
=end

Actions #2

Updated by darix (Marcus Rückert) about 12 years ago

=begin
On 2010-07-30 06:57:25 +0900, Tomas Matousek wrote:

"~a" should be considered a regular file name and as such should be prefixed with the current directory path like any other file name.

it shouldnt "~a" means "home directory of user 'a'". '~/' is just a
shorthand for '~/'

on linux you get:

File.expand_path('~a')
ArgumentError: user a doesn't exist

maybe that user check is skipped on windows?

 darix

--
openSUSE - SUSE Linux is my linux
openSUSE is good for you
www.opensuse.org

=end

Actions #3

Updated by tmat (Tomas Matousek) about 12 years ago

=begin
I see. Then on Windows it might check for existence of directory ENV[HOME]/../a. I guess that might be a good approximation.
=end

Actions #4

Updated by luislavena (Luis Lavena) about 12 years ago

=begin
Well, no.

Normally HOME is not defined in Windows, instead things like USERPROFILE points to your local profile folder (Document and Settings or Users).

Other times, in case of corporate environment where you have a Roaming profile, you have setup HOMEDRIVE and HOMEPATH.

HOMEDRIVE+HOMEPATH might point to a particular folder that warrants is yours, but there is no granted that ../ will be the common location for other users.

=end

Actions #5

Updated by nobu (Nobuyoshi Nakada) about 12 years ago

=begin
Fixed at [ruby-core:31537]" href="/projects/ruby-193/repository/22/revisions/28796">r28796.

BTW, please avoid filing Bug issues to 1.9.1, unless it is particular to 1.9.1.
In general, 1.9.1 should accept Backport issues only.
=end

Actions #6

Updated by nobu (Nobuyoshi Nakada) about 12 years ago

  • Status changed from Open to Closed

=begin

=end

Actions #7

Updated by nobu (Nobuyoshi Nakada) about 12 years ago

  • Category set to core

=begin
Sorry, it was [ruby-core:31538]" href="/projects/ruby-193/repository/22/revisions/28795">r28795.
=end

Actions #8

Updated by nobu (Nobuyoshi Nakada) about 12 years ago

  • Category set to core
  • Status changed from Closed to Assigned
  • Assignee set to yugui (Yuki Sonoda)
  • Priority changed from Normal to 3

=begin

=end

Actions #9

Updated by tmat (Tomas Matousek) about 12 years ago

=begin
So how do you detect whether a user dir exists or not or Windows then? Or do you throw on Windows for any user other than the current one?
=end

Updated by kosaki (Motohiro KOSAKI) almost 11 years ago

I don't understand why we have to backport low priority issue. Can anyone explain it?

Updated by nobu (Nobuyoshi Nakada) almost 11 years ago

I'm not sure if it's worth backporting to 1.9.2, so had left the decision to yugui.

Updated by nobu (Nobuyoshi Nakada) almost 11 years ago

Sorry, 1.9.2 already has it.
And I don't think this can be backported to 1.9.1.

Updated by nobu (Nobuyoshi Nakada) almost 11 years ago

  • Status changed from Assigned to Closed
Actions

Also available in: Atom PDF