Backport #3629
closedexpand_path doesn't expand "~a"
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
Updated by luislavena (Luis Lavena) over 14 years ago
=begin
I believe this is related to [ruby-core:18319]
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/18319
=end
Updated by darix (Marcus Rückert) over 14 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
Updated by tmat (Tomas Matousek) over 14 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
Updated by luislavena (Luis Lavena) over 14 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
Updated by nobu (Nobuyoshi Nakada) over 14 years ago
=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
Updated by nobu (Nobuyoshi Nakada) over 14 years ago
- Category set to core
=begin
Sorry, it was r28795.
=end
Updated by nobu (Nobuyoshi Nakada) over 14 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
Updated by tmat (Tomas Matousek) over 14 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) about 13 years ago
I don't understand why we have to backport low priority issue. Can anyone explain it?
Updated by nobu (Nobuyoshi Nakada) about 13 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) about 13 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) about 13 years ago
- Status changed from Assigned to Closed