Propagate exit status in ExecutioError exception
This commit is contained in:
parent
0ec10c68ca
commit
1e879eaee8
@ -235,7 +235,7 @@ protected
|
||||
end
|
||||
end
|
||||
rescue
|
||||
raise BuildError.new(cmd, args)
|
||||
raise BuildError.new(cmd, args, $?)
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -57,8 +57,11 @@ HOMEBREW_USER_AGENT = "Homebrew #{HOMEBREW_VERSION} (Ruby #{RUBY_VERSION}-#{RUBY
|
||||
|
||||
|
||||
class ExecutionError <RuntimeError
|
||||
def initialize cmd, args=[]
|
||||
attr :status
|
||||
|
||||
def initialize cmd, args=[], status=nil
|
||||
super "Failure while executing: #{cmd} #{args*' '}"
|
||||
@status = status
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -86,13 +86,10 @@ def safe_system cmd, *args
|
||||
puts "#{cmd} #{args*' '}" if ARGV.verbose?
|
||||
exec_success = Kernel.system cmd, *args
|
||||
# some tools, eg. tar seem to confuse ruby and it doesn't propogate the
|
||||
# CTRL-C interrupt to us too, so execution continues, but the exit code os
|
||||
# CTRL-C interrupt to us too, so execution continues, but the exit code is
|
||||
# still 2 so we raise our own interrupt
|
||||
raise Interrupt, cmd if $?.termsig == 2
|
||||
unless exec_success
|
||||
puts "Exit code: #{$?}"
|
||||
raise ExecutionError.new(cmd, args)
|
||||
end
|
||||
raise ExecutionError.new(cmd, args, $?) unless exec_success
|
||||
end
|
||||
|
||||
def curl *args
|
||||
@ -146,7 +143,6 @@ def arch_for_command cmd
|
||||
return archs
|
||||
end
|
||||
|
||||
|
||||
# replaces before with after for the file path
|
||||
def inreplace path, before, after
|
||||
f = File.open(path, 'r')
|
||||
|
9
bin/brew
9
bin/brew
@ -70,8 +70,8 @@ EOS
|
||||
end
|
||||
|
||||
def please_report_bug; <<-EOS
|
||||
Please report this bug to #{HOMEBREW_WWW} including the following information:
|
||||
Mac OS X: #{MACOS_VERSION}
|
||||
Please report this bug to #{HOMEBREW_WWW}
|
||||
Mac OS X: #{MACOS_FULL_VERSION}
|
||||
Ponk: #{macports_or_fink_installed?}
|
||||
EOS
|
||||
end
|
||||
@ -263,7 +263,10 @@ rescue SystemCallError, RuntimeError => e
|
||||
puts e.backtrace
|
||||
else
|
||||
onoe e
|
||||
puts please_report_bug if e.kind_of? BuildError
|
||||
if e.kind_of? BuildError
|
||||
puts please_report_bug
|
||||
puts "Exit Status: #{e.status}"
|
||||
end
|
||||
end
|
||||
exit 1
|
||||
rescue Exception => e
|
||||
|
Loading…
x
Reference in New Issue
Block a user