1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Use File.expand_path("~username") instead of ENV["HOME"]

File.expand_path("~username") uses getpwnam() independently from
Dir.home. [Bug #15324]

From: Chris Seaton <chris@chrisseaton.com>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65926 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
naruse 2018-11-22 10:43:42 +00:00
parent 0bd8193eba
commit 4e1ee66580

View file

@ -374,8 +374,7 @@ class TestDir < Test::Unit::TestCase
assert_equal(@nodir, Dir.home)
assert_equal(@nodir, Dir.home(""))
if user = ENV["USER"]
ENV["HOME"] = env_home
assert_equal(File.expand_path(env_home), Dir.home(user))
assert_equal(File.expand_path("~#{user}"), Dir.home(user))
end
}
%W[no:such:user \u{7559 5b88}:\u{756a}].each do |user|