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

ruby-changes:26297

From: nobu <ko1@a...>
Date: Wed, 12 Dec 2012 21:41:04 +0900 (JST)
Subject: [ruby-changes:26297] nobu:r38348 (trunk): tmpdir.rb: not expand tilde

nobu	2012-12-12 21:40:51 +0900 (Wed, 12 Dec 2012)

  New Revision: 38348

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38348

  Log:
    tmpdir.rb: not expand tilde
    
    * lib/tmpdir.rb (Dir::Tmpname#create): deal with a prefix name which
      starts with tilde as a plain name, not expanding as home directory.
      [ruby-core:50793] [Bug #7547]

  Modified files:
    trunk/ChangeLog
    trunk/lib/tmpdir.rb
    trunk/test/test_tmpdir.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 38347)
+++ ChangeLog	(revision 38348)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Dec 12 21:40:45 2012  Nobuyoshi Nakada  <nobu@r...>
+
+	* lib/tmpdir.rb (Dir::Tmpname#create): deal with a prefix name which
+	  starts with tilde as a plain name, not expanding as home directory.
+	  [ruby-core:50793] [Bug #7547]
+
 Wed Dec 12 19:48:59 2012  NARUSE, Yui  <naruse@r...>
 
 	* ext/json: merge JSON 1.7.5.
Index: lib/tmpdir.rb
===================================================================
--- lib/tmpdir.rb	(revision 38347)
+++ lib/tmpdir.rb	(revision 38348)
@@ -138,7 +138,7 @@ class Dir https://github.com/ruby/ruby/blob/trunk/lib/tmpdir.rb#L138
       end
       n = nil
       begin
-        path = File.expand_path(make_tmpname(basename, n), tmpdir)
+        path = File.join(tmpdir, make_tmpname(basename, n))
         yield(path, n, *opts)
       rescue Errno::EEXIST
         n ||= 0
Index: test/test_tmpdir.rb
===================================================================
--- test/test_tmpdir.rb	(revision 38347)
+++ test/test_tmpdir.rb	(revision 38348)
@@ -18,4 +18,15 @@ class TestTmpdir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/test_tmpdir.rb#L18
       end
     end
   end
+
+  def test_no_homedir
+    bug7547 = '[ruby-core:50793]'
+    home, ENV["HOME"] = ENV["HOME"], nil
+    dir = assert_nothing_raised(bug7547) do
+      break Dir.mktmpdir("~")
+    end
+    assert_match(/\A~/, File.basename(dir), bug7547)
+  ensure
+    ENV["HOME"] = home
+  end
 end

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

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