diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-12 12:40:51 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-12-12 12:40:51 +0000 |
commit | 6f8bce9eff15b527c87e1b13312db2fbf0b504f4 (patch) | |
tree | fcccd01968dcae2fdc28486734447a1918815e77 | |
parent | 0a577a1ce090c1661abfd74502e45aa13a488835 (diff) |
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]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/tmpdir.rb | 2 | ||||
-rw-r--r-- | test/test_tmpdir.rb | 11 |
3 files changed, 18 insertions, 1 deletions
@@ -1,3 +1,9 @@ +Wed Dec 12 21:40:45 2012 Nobuyoshi Nakada <[email protected]> + + * 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 <[email protected]> * 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 |