Project

General

Profile

Backport #3629

expand_path doesn't expand "~a"

Added by tmat (Tomas Matousek) about 9 years ago. Updated almost 8 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

History

#1

Updated by luislavena (Luis Lavena) about 9 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

#2

Updated by darix (Marcus Rückert) about 9 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

#3

Updated by tmat (Tomas Matousek) about 9 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

#4

Updated by luislavena (Luis Lavena) about 9 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

#5

Updated by nobu (Nobuyoshi Nakada) about 9 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

#6

Updated by nobu (Nobuyoshi Nakada) about 9 years ago

  • Status changed from Open to Closed

=begin

=end

#7

Updated by nobu (Nobuyoshi Nakada) about 9 years ago

  • Category set to core

=begin
Sorry, it was r28795.
=end

#8

Updated by nobu (Nobuyoshi Nakada) about 9 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

#9

Updated by tmat (Tomas Matousek) about 9 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 8 years ago

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

Updated by nobu (Nobuyoshi Nakada) almost 8 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 8 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 8 years ago

  • Status changed from Assigned to Closed

Also available in: Atom PDF