diff options
-rw-r--r-- | lib/puppet/parser/functions/validate_cmd.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/puppet/parser/functions/validate_cmd.rb b/lib/puppet/parser/functions/validate_cmd.rb index e7793c3..00fe1ae 100644 --- a/lib/puppet/parser/functions/validate_cmd.rb +++ b/lib/puppet/parser/functions/validate_cmd.rb @@ -28,11 +28,14 @@ module Puppet::Parser::Functions # Test content in a temporary file tmpfile = Tempfile.new("validate_cmd") - tmpfile.write(content) - tmpfile.close - output = `#{checkscript} #{tmpfile.path} 2>&1 1>/dev/null` - r = $? - File.delete(tmpfile.path) + begin + tmpfile.write(content) + output = `#{checkscript} #{tmpfile.path} 2>&1 1>/dev/null` + r = $? + ensure + tmpfile.close + tmpfile.unlink + end if output msg += "\nOutput is:\n#{output}" end |