Skip to content

Commit

Permalink
verbose-shell: system_or_true -> system_noraise and make it return th…
Browse files Browse the repository at this point in the history
…e exit code
  • Loading branch information
caldwell committed Mar 26, 2021
1 parent 3413716 commit 6386a74
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions verbose-shell.rb
Expand Up @@ -34,16 +34,18 @@ def system(*args)
system_trace *args
args, opts = args.last.is_a?(Hash) ? [args[0..-2], args.last.dup] : [args, {}]
if opts.delete(:loud) or @verbose > 0
Kernel.system(*args, opts) or raise ShellError.new('', args, $?.exitstatus).message.lstrip
Kernel.system(*args, opts) or raise ShellError.new('', args, $?.exitstatus)
else
output = IO.popen(args, opts.merge({:err => [:child, :out]})) {|io| io.read}
raise ShellError.new(output, args, $?.exitstatus) if $? != 0
end
$?
end

def system_or_true(*args)
def system_noraise(*args)
system *args
rescue
rescue ShellError => e
e.exit_code
end

def capture(*args) # ``
Expand Down

0 comments on commit 6386a74

Please sign in to comment.