Skip to content

Commit fb4a1dc

Browse files
authored
Merge pull request #8824 from joshcooper/ruby_patch_no_shell_expand_5800
2 parents 5a86a5f + f916a17 commit fb4a1dc

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/puppet/file_system/uniquefile.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def create_tmpname(basename, *rest)
127127
tmpdir ||= tmpdir()
128128
n = nil
129129
begin
130-
path = File.expand_path(make_tmpname(basename, n), tmpdir)
130+
path = File.join(tmpdir, make_tmpname(basename, n))
131131
yield(path, n, *opts)
132132
rescue Errno::EEXIST
133133
n ||= 0

spec/unit/file_system/uniquefile_spec.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
lock = File.join(dir, 'path', 'to', 'lock')
8181

8282
expect {
83-
Puppet::FileSystem::Uniquefile.open_tmp(lock) { |tmp| }
83+
Puppet::FileSystem::Uniquefile.new('foo', lock) { |tmp| }
8484
}.to raise_error(Errno::ENOENT, %r{No such file or directory - A directory component in .* does not exist or is a dangling symbolic link})
8585
end
8686

@@ -102,6 +102,12 @@
102102
expect(filename).to eq(temp_rune_utf8)
103103
end
104104

105+
it "preserves tilde characters" do
106+
Puppet::FileSystem::Uniquefile.open_tmp('~foo') do |file|
107+
expect(File.basename(file.path)).to start_with('~foo')
108+
end
109+
end
110+
105111
context "Ruby 1.9.3 Tempfile tests" do
106112
# the remaining tests in this file are ported directly from the ruby 1.9.3 source,
107113
# since most of this file was ported from there

0 commit comments

Comments
 (0)