From 683ac8f8aa5f349ece98165d92a8d271b99b855e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Pinson?= Date: Tue, 5 Feb 2013 09:01:48 +0100 Subject: validate_cmd: Use Puppet::Util.execute --- lib/puppet/parser/functions/validate_cmd.rb | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'lib/puppet/parser/functions/validate_cmd.rb') diff --git a/lib/puppet/parser/functions/validate_cmd.rb b/lib/puppet/parser/functions/validate_cmd.rb index 00fe1ae..4f6a766 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. @@ -30,15 +32,12 @@ module Puppet::Parser::Functions tmpfile = Tempfile.new("validate_cmd") begin tmpfile.write(content) - output = `#{checkscript} #{tmpfile.path} 2>&1 1>/dev/null` - r = $? + Puppet::Util.execute("#{checkscript} #{tmpfile.path}") + rescue Puppet::ExecutionFailure => detail + msg += "\n#{detail}" + raise Puppet::ParseError, msg ensure - tmpfile.close tmpfile.unlink end - if output - msg += "\nOutput is:\n#{output}" - end - raise Puppet::ParseError, (msg) unless r == 0 end end -- cgit v1.2.3