Backport #3629
closed
expand_path doesn't expand "~a"
Added by tmat (Tomas Matousek) over 14 years ago.
Updated about 13 years ago.
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
=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
=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
=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
=begin
Fixed at 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
- Status changed from Open to Closed
=begin
Sorry, it was r28795.
=end
- Category set to core
- Status changed from Closed to Assigned
- Assignee set to yugui (Yuki Sonoda)
- Priority changed from Normal to 3
=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
I don't understand why we have to backport low priority issue. Can anyone explain it?
I'm not sure if it's worth backporting to 1.9.2, so had left the decision to yugui.
Sorry, 1.9.2 already has it.
And I don't think this can be backported to 1.9.1.
- Status changed from Assigned to Closed
Also available in: Atom
PDF
Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0