Project

General

Profile

This project is closed and read-only.

Actions

Backport #3629

closed

expand_path doesn't expand "~a"

Backport #3629: expand_path doesn't expand "~a"

Added by tmat (Tomas Matousek) about 16 years ago. Updated almost 15 years ago.

Status:
Closed
[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

Updated by darix (Marcus Rückert) about 16 years ago Actions #2

=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) about 16 years ago Actions #3

=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) about 16 years ago Actions #4

=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) about 16 years ago Actions #5

=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) about 16 years ago Actions #6

  • Status changed from Open to Closed

=begin

=end

Updated by nobu (Nobuyoshi Nakada) about 16 years ago Actions #7

  • Category set to core

=begin
Sorry, it was r28795.
=end

Updated by nobu (Nobuyoshi Nakada) about 16 years ago Actions #8

  • 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) about 16 years ago Actions #9

=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 15 years ago Actions #10 [ruby-core:40056]

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

Updated by nobu (Nobuyoshi Nakada) almost 15 years ago Actions #11 [ruby-core:40069]

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 15 years ago Actions #12 [ruby-core:40070]

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 15 years ago Actions #13 [ruby-core:40071]

  • Status changed from Assigned to Closed
Actions

Also available in: PDF Atom