Add quiet_system
Same as Kernel.system, but prints no output.
This commit is contained in:
parent
0a27f041d0
commit
df79d74e13
@ -84,16 +84,31 @@ def interactive_shell
|
||||
end
|
||||
end
|
||||
|
||||
# Kernel.system but with exceptions
|
||||
def safe_system cmd, *args
|
||||
module Homebrew
|
||||
def self.system cmd, *args
|
||||
puts "#{cmd} #{args*' '}" if ARGV.verbose?
|
||||
fork do
|
||||
yield if block_given?
|
||||
args.collect!{|arg| arg.to_s}
|
||||
exec(cmd, *args) rescue nil
|
||||
exit! 1 # never gets here unless exec failed
|
||||
end
|
||||
Process.wait
|
||||
raise ExecutionError.new(cmd, args, $?) unless $?.success?
|
||||
$?.success?
|
||||
end
|
||||
end
|
||||
|
||||
# Kernel.system but with exceptions
|
||||
def safe_system cmd, *args
|
||||
raise ExecutionError.new(cmd, args, $?) unless Homebrew.system(cmd, *args)
|
||||
end
|
||||
|
||||
# prints no output
|
||||
def quiet_system cmd, *args
|
||||
Homebrew.system(cmd, *args) do
|
||||
$stdout.close
|
||||
$stderr.close
|
||||
end
|
||||
end
|
||||
|
||||
def curl *args
|
||||
|
Loading…
x
Reference in New Issue
Block a user