summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util.rb
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2008-11-19 18:44:41 +1100
committerJames Turnbull <james@lovedthanlost.net>2008-11-19 18:44:41 +1100
commitd32d7f30f672e59c1427d9dfe32e7b7be35a48ab (patch)
treeed63bf3784ff3d4cffa7e00780876bd87522b4db /lib/puppet/util.rb
parent43967408a166ca4155b1febae987300b2b327f97 (diff)
downloadpuppet-d32d7f30f672e59c1427d9dfe32e7b7be35a48ab.tar.gz
puppet-d32d7f30f672e59c1427d9dfe32e7b7be35a48ab.tar.xz
puppet-d32d7f30f672e59c1427d9dfe32e7b7be35a48ab.zip
Fixed #1752 - Add an optional argument to Puppet::Util.execute to determine whether stderr and stdout are combined in the output
Diffstat (limited to 'lib/puppet/util.rb')
-rw-r--r--lib/puppet/util.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb
index 59f732dae..09c94c3c9 100644
--- a/lib/puppet/util.rb
+++ b/lib/puppet/util.rb
@@ -268,7 +268,7 @@ module Util
# Execute the desired command, and return the status and output.
# def execute(command, failonfail = true, uid = nil, gid = nil)
- def execute(command, arguments = {:failonfail => true})
+ def execute(command, arguments = {:failonfail => true, :combine => true})
if command.is_a?(Array)
command = command.flatten.collect { |i| i.to_s }
str = command.join(" ")
@@ -301,9 +301,13 @@ module Util
# The idea here is to avoid IO#read whenever possible.
output_file="/dev/null"
+ error_file="/dev/null"
if ! arguments[:squelch]
require "tempfile"
output_file = Tempfile.new("puppet")
+ if arguments[:combine]
+ error_file=output_file
+ end
end
oldverb = $VERBOSE
@@ -319,7 +323,8 @@ module Util
begin
$stdin.reopen("/dev/null")
$stdout.reopen(output_file)
- $stderr.reopen(output_file)
+ $stderr.reopen(error_file)
+
3.upto(256){|fd| IO::new(fd).close rescue nil}
if arguments[:gid]
Process.egid = arguments[:gid]