summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAdrien Thebo <git@somethingsinistral.net>2013-02-12 10:20:22 -0800
committerAdrien Thebo <git@somethingsinistral.net>2013-02-12 10:20:22 -0800
commit36a7b29630a4d4de17af79b5dd4e9491ec20b123 (patch)
tree5aaf8094fb3f3933ed3677efb6401bb8a4ff676c /lib
parent15266d9b44aea29b7838186818fd88ad2f59faf9 (diff)
parent69248dfd8ab09f6d78054d10c7162bb18ec040e5 (diff)
downloadpuppet-stdlib-36a7b29630a4d4de17af79b5dd4e9491ec20b123.tar.gz
puppet-stdlib-36a7b29630a4d4de17af79b5dd4e9491ec20b123.tar.bz2
Merge branch 'pull-126'
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/parser/functions/validate_cmd.rb22
1 files changed, 14 insertions, 8 deletions
diff --git a/lib/puppet/parser/functions/validate_cmd.rb b/lib/puppet/parser/functions/validate_cmd.rb
index e7793c3..344a80c 100644
--- a/lib/puppet/parser/functions/validate_cmd.rb
+++ b/lib/puppet/parser/functions/validate_cmd.rb
@@ -1,3 +1,5 @@
+require 'puppet/util/execution'
+
module Puppet::Parser::Functions
newfunction(:validate_cmd, :doc => <<-'ENDHEREDOC') do |args|
Perform validation of a string with an external command.
@@ -28,14 +30,18 @@ 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)
- if output
- msg += "\nOutput is:\n#{output}"
+ begin
+ tmpfile.write(content)
+ if Puppet::Util::Execution.respond_to?('execute')
+ Puppet::Util::Execution.execute("#{checkscript} #{tmpfile.path}")
+ else
+ Puppet::Util.execute("#{checkscript} #{tmpfile.path}")
+ end
+ rescue Puppet::ExecutionFailure => detail
+ msg += "\n#{detail}"
+ raise Puppet::ParseError, msg
+ ensure
+ tmpfile.unlink
end
- raise Puppet::ParseError, (msg) unless r == 0
end
end