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

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
This commit is contained in:
nobu 2012-12-12 12:40:51 +00:00
parent 0a577a1ce0
commit 6f8bce9eff
3 changed files with 18 additions and 1 deletions

View file

@ -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> Wed Dec 12 19:48:59 2012 NARUSE, Yui <naruse@ruby-lang.org>
* ext/json: merge JSON 1.7.5. * ext/json: merge JSON 1.7.5.

View file

@ -138,7 +138,7 @@ class Dir
end end
n = nil n = nil
begin begin
path = File.expand_path(make_tmpname(basename, n), tmpdir) path = File.join(tmpdir, make_tmpname(basename, n))
yield(path, n, *opts) yield(path, n, *opts)
rescue Errno::EEXIST rescue Errno::EEXIST
n ||= 0 n ||= 0

View file

@ -18,4 +18,15 @@ class TestTmpdir < Test::Unit::TestCase
end end
end 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 end