Issue #8034 has been updated by luislavena (Luis Lavena).

Assignee changed from luislavena (Luis Lavena) to h.shirosaki (Hiroshi Shirosaki)
% Done changed from 50 to 70

=begin
Shirosaki-san,

I've refactored the code, would you mind take a look?

https://gist.github.com/luislavena/5148562

After applying the patch, it fixes the original issue, however now nobu-san added another test:

 assert_nothing_raised(ArgumentError) { File.expand_path("/", UnknownUserHome) }

Which requires more conditions if (({fname})) is '/' and set (({ignore_dir})) accordingly, but I'm confused about the scenario.

I'm not sure if that scenario is portable and correct since 1.8.7 and 1.9.2 return ArgumentError:

 C:\Users\Luis>ruby -ve "p File.expand_path('/', '~foo')"
 ruby 1.8.7 (2012-10-12 patchlevel 371) [i386-mingw32]
 -e:1:in `expand_path': can't find user ~foo (ArgumentError)
         from -e:1

 C:\Users\Luis>ruby -ve "p File.expand_path('/', '~foo')"
 ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
 -e:1:in `expand_path': can't find user foo (ArgumentError)
         from -e:1:in `<main>'

Thoughts?

=end
----------------------------------------
Bug #8034: File.expand_path('something', '~') do not include home path
https://bugs.ruby-lang.org/issues/8034#change-37550

Author: rap-kasta (Pavel Manylov)
Status: Assigned
Priority: Normal
Assignee: h.shirosaki (Hiroshi Shirosaki)
Category: platform/windows
Target version: 
ruby -v: 1.9.3p362


=begin
Next code works correctly only on ruby <= 1.9.3p362.
Tested on Windows XP, Windows 2008 with ruby 1.9.3p194 (works properly), ruby 1.9.3p362 (bug), ruby 2.0.0p0 (bug).

(({File.expand_path('something', '~') #=> "C:/path/to/current/dir/~/something"}))
                    
However, next code works as it should in all tested rubies:

(({File.expand_path '~' # => "C:/Documents and Settings/Jack"
Dir.home # => "C:/Documents and Settings/Jack"}))
=end



-- 
http://bugs.ruby-lang.org/