diff options
| author | Max Howell | 2009-09-05 20:46:07 +0100 |
|---|---|---|
| committer | Max Howell | 2009-09-05 20:46:07 +0100 |
| commit | 680e2019233c8ed17a62ce2cb2d8308b3593d977 (patch) | |
| tree | 2a2560f907f971cfe29f3ac70f92133eb0bf33dc | |
| parent | 64e767155a8322d051ea7ff57a5bedf1f237ae2e (diff) | |
| download | brew-680e2019233c8ed17a62ce2cb2d8308b3593d977.tar.bz2 | |
Fix double newline after Interrupt
Seems to be an issue with Ruby system() call doing a double fork.
| -rw-r--r-- | Library/Homebrew/formula.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/utils.rb | 9 | ||||
| -rwxr-xr-x | bin/brew | 5 |
3 files changed, 10 insertions, 6 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index a13ed3866..55293ca80 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -23,7 +23,7 @@ # class ExecutionError <RuntimeError def initialize cmd, args=[] - super "#{cmd} #{args*' '}" + super "Failure while executing: #{cmd} #{args*' '}" end end class BuildError <ExecutionError diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index 0dd26d49b..d01436c78 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -64,11 +64,12 @@ end # Kernel.system but with exceptions def safe_system cmd, *args puts "#{cmd} #{args*' '}" if ARGV.verbose? - - execd=Kernel.system cmd, *args - # somehow Ruby doesn't handle the CTRL-C from another process -- WTF!? + 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 + # still 2 so we raise our own interrupt raise Interrupt, cmd if $?.termsig == 2 - raise ExecutionError.new(cmd, args) unless execd and $? == 0 + raise ExecutionError.new(cmd, args) unless exec_success and $?.success? end def curl url, *args @@ -210,7 +210,10 @@ rescue UsageError rescue SystemExit ohai "Kernel.exit" if ARGV.verbose? rescue Interrupt => e - puts # seemingly a newline is typical + # puts # seemingly a newline is typical + # Above is now commented out because the system() call forks and then forks + # again, so there are two of "us" so we get two exceptions raising and thus + # two newlines, which buggers up the shell. FIXME! exit 130 rescue SystemCallError, RuntimeError => e if ARGV.debug? |
