summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--lib/tmpdir.rb2
-rw-r--r--test/test_tmpdir.rb11
3 files changed, 18 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 87e2037c00..d5a23be544 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Dec 12 21:40:45 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* ext/json: merge JSON 1.7.5.
diff --git a/lib/tmpdir.rb b/lib/tmpdir.rb
index 03c02fd788..18d4fb683d 100644
--- a/lib/tmpdir.rb
+++ b/lib/tmpdir.rb
@@ -138,7 +138,7 @@ class Dir
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
diff --git a/test/test_tmpdir.rb b/test/test_tmpdir.rb
index c48b4b7fb2..61d3f60213 100644
--- a/test/test_tmpdir.rb
+++ b/test/test_tmpdir.rb
@@ -18,4 +18,15 @@ class TestTmpdir < Test::Unit::TestCase
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