Added double quotes to paths in concat command, so that it does not fail when path of target file contains some blanks.

This commit is contained in:
Lucien Weller 2014-02-21 19:17:41 +01:00
parent 24906d1bca
commit a2f625f385
3 changed files with 36 additions and 3 deletions

View file

@ -177,7 +177,7 @@ define concat(
}
# remove extra whitespace from string interpolation to make testing easier
$command = strip(regsubst("${script_command} -o ${fragdir}/${concat_name} -d ${fragdir} ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", '\s+', ' ', 'G'))
$command = strip(regsubst("${script_command} -o \"${fragdir}/${concat_name}\" -d \"${fragdir}\" ${warnflag} ${forceflag} ${orderflag} ${newlineflag}", '\s+', ' ', 'G'))
# if puppet is running as root, this exec should also run as root to allow
# the concatfragments.sh script to potentially be installed in path that

View file

@ -0,0 +1,33 @@
require 'spec_helper_acceptance'
describe 'quoted paths' do
before(:all) do
shell('rm -rf "/tmp/concat test" /var/lib/puppet/concat')
shell('mkdir -p "/tmp/concat test"')
end
context 'path with blanks' do
pp = <<-EOS
concat { '/tmp/concat test/foo':
}
concat::fragment { '1':
target => '/tmp/concat test/foo',
content => 'string1',
}
concat::fragment { '2':
target => '/tmp/concat test/foo',
content => 'string2',
}
EOS
it 'applies the manifest twice with no stderr' do
expect(apply_manifest(pp, :catch_failures => true).stderr).to eq("")
expect(apply_manifest(pp, :catch_changes => true).stderr).to eq("")
end
describe file('/tmp/concat test/foo') do
it { should be_file }
it { should contain "string1\nsring2" }
end
end
end

View file

@ -81,8 +81,8 @@ describe 'concat', :type => :define do
end
cmd = "#{concatdir}/bin/concatfragments.sh " +
"-o #{concatdir}/#{safe_name}/fragments.concat.out " +
"-d #{concatdir}/#{safe_name}"
"-o \"#{concatdir}/#{safe_name}/fragments.concat.out\" " +
"-d \"#{concatdir}/#{safe_name}\""
# flag order: fragdir, warnflag, forceflag, orderflag, newlineflag
if p.has_key?(:warn)