lib/rbbt/util/cmd.rb in rbbt-util-5.5.68 vs lib/rbbt/util/cmd.rb in rbbt-util-5.6.0

- old
+ new

@@ -31,13 +31,16 @@ Log.debug{"Process #{ cmd } succeded" if $? and $?.success? and log} if $? and not $?.success? Log.debug{"Raising exception" if log} - exception = CMDError.new "Command [#{@pid}] #{@cmd} failed with error status #{$?.exitstatus}" - original_close - raise exception + exception = CMDError.new "Command [#{@pid}] '#{@cmd}' failed with error status #{$?.exitstatus}" + begin + original_close + ensure + raise exception + end end end end def close @@ -95,10 +98,10 @@ string.strip end def self.cmd(cmd, options = {}, &block) - options[:stderr] ||= Log::DEBUG + options = Misc.add_defaults options, :stderr => Log::DEBUG in_content = options.delete(:in) stderr = options.delete(:stderr) pipe = options.delete(:pipe) post = options.delete(:post) log = options.delete(:log)