[前][次][番号順一覧][スレッド一覧]

ruby-changes:53710

From: naruse <ko1@a...>
Date: Thu, 22 Nov 2018 19:43:48 +0900 (JST)
Subject: [ruby-changes:53710] naruse:r65926 (trunk): Use File.expand_path("~username") instead of ENV["HOME"]

naruse	2018-11-22 19:43:42 +0900 (Thu, 22 Nov 2018)

  New Revision: 65926

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=65926

  Log:
    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@c...>

  Modified files:
    trunk/test/ruby/test_dir.rb
Index: test/ruby/test_dir.rb
===================================================================
--- test/ruby/test_dir.rb	(revision 65925)
+++ test/ruby/test_dir.rb	(revision 65926)
@@ -374,8 +374,7 @@ class TestDir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_dir.rb#L374
       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|

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]