Bug #3630: File.expand_path doesn't expand content of HOME env. variable
http://redmine.ruby-lang.org/issues/show/3630

Author: Tomas Matousek
Status: Open, Priority: Normal
ruby -v: ruby 1.9.1p378 (2010-01-10 revision 26273) [i386-mingw32]

Dir.chdir 'C:/temp' do
  p File.expand_path("a")

  ENV["HOME"] = './abc/../xxx'
  p File.expand_path("~/a")

  ENV["HOME"] = '~/xxx'
  p File.expand_path("~/a")
end

Prints:

"C:/temp/a"
"./abc/../xxx/a"
"~/xxx/a"

I'd expect it to print:
"C:/temp/a"
"C:/temp/xxx/a"
"C:/temp/~/xxx/a"

The content of HOME variable should be subject to expansion. If it starts with ~/ the tilde should be treated like a regular directory name to avoid recursion.


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