aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xLibrary/Homebrew/install.rb13
-rwxr-xr-xbin/brew22
2 files changed, 23 insertions, 12 deletions
diff --git a/Library/Homebrew/install.rb b/Library/Homebrew/install.rb
index f3ddd34bb..927e976bc 100755
--- a/Library/Homebrew/install.rb
+++ b/Library/Homebrew/install.rb
@@ -137,9 +137,16 @@ def install f
puts
rescue Exception => e
- #TODO propogate exception back to brew script
- onoe e
- puts e.backtrace
+ if ENV['HOMEBREW_ERROR_PIPE']
+ pipe = IO.new(ENV['HOMEBREW_ERROR_PIPE'].to_i, 'w')
+ Marshal.dump(e, pipe)
+ pipe.close
+ exit! 1
+ else
+ onoe e
+ puts e.backtrace
+ exit! 2
+ end
end
diff --git a/bin/brew b/bin/brew
index 3e756ccb9..2195e3a20 100755
--- a/bin/brew
+++ b/bin/brew
@@ -163,17 +163,21 @@ begin
# the easiest way to do this
# 2. formulae have access to __END__ the only way to allow this is
# to make the formula script the executed script
- pid=fork
- if pid.nil?
- exec '/usr/bin/ruby', '-I', homebrew_rubylib_path, '-rinstall', f.path, '--', *ARGV.options
- else
- Process.wait pid
- end
- #FIXME I don't think $? represents the exit code from the child fork…
- exit! $? if $? != 0 # exception in other brew will be visible on screen
+ read, write = IO.pipe
+ # I'm guessing this is not a good way to do this, but I'm no UNIX guru
+ ENV['HOMEBREW_ERROR_PIPE'] = write.to_i.to_s
+
+ if not fork
+ read.close
+ exec '/usr/bin/ruby', '-I', homebrew_rubylib_path, '-rinstall', f.path, '--', *ARGV.options
+ else
+ write.close
+ data = read.read
+ raise Marshal.load(data) unless data.nil? or data.empty?
+ Process.wait
end
end
-
+ end
when 'up', 'update'
require 'update'