aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils.rb
diff options
context:
space:
mode:
authorMax Howell2009-11-09 17:44:29 +0000
committerMax Howell2009-11-09 17:55:11 +0000
commit1da26d89ea2d2cf5a45c8852288291de6a13d184 (patch)
treecd44ce759119c1e51709bf43424c463bf9295999 /Library/Homebrew/utils.rb
parent590f64e302d99b02c28bac383752f8190f6a02c6 (diff)
downloadbrew-1da26d89ea2d2cf5a45c8852288291de6a13d184.tar.bz2
Don't use Kernel.system much
It just seems to behave strangely with SIGINT. Eg. SIGINT causes tar to exit, but the SIGINT is ignored by our process. This is not the case when used with curl.
Diffstat (limited to 'Library/Homebrew/utils.rb')
-rw-r--r--Library/Homebrew/utils.rb22
1 files changed, 12 insertions, 10 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index e30512ff9..d980c328c 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -69,27 +69,29 @@ def pretty_duration s
end
def interactive_shell
- pid=fork
- if pid.nil?
+ fork do
# TODO make the PS1 var change pls
#brown="\[\033[0;33m\]"
#reset="\[\033[0m\]"
#ENV['PS1']="Homebrew-#{HOMEBREW_VERSION} #{brown}\W#{reset}\$ "
exec ENV['SHELL']
end
- Process.wait pid
- raise SystemExit, "Aborting due to non-zero exit status" if $? != 0
+ Process.wait
+ unless $?.success?
+ puts "Aborting due to non-zero exit status"
+ exit $?
+ end
end
# Kernel.system but with exceptions
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 is
- # still 2 so we raise our own interrupt
- raise Interrupt, cmd if $?.termsig == 2
- raise ExecutionError.new(cmd, args, $?) unless exec_success
+ fork do
+ trap("EXIT") {} # no bt on exit from this short-lived fork
+ exit! 1 unless exec(cmd, *args)
+ end
+ Process.wait
+ raise ExecutionError.new(cmd, args, $?) unless $?.success?
end
def curl *args