Use our own popen implementation in Formula.system
The rationale here is that the --verbose mode had a bug where it didn't escape its parameters properly. Which caused ocassionally cryptic issues.
This commit is contained in:
parent
1e879eaee8
commit
22afc5e1c7
@ -216,20 +216,24 @@ protected
|
||||
# Pretty titles the command and buffers stdout/stderr
|
||||
# Throws if there's an error
|
||||
def system cmd, *args
|
||||
full="#{cmd} #{args*' '}".strip
|
||||
ohai full
|
||||
ohai "#{cmd} #{args*' '}".strip
|
||||
|
||||
if ARGV.verbose?
|
||||
safe_system cmd, *args
|
||||
else
|
||||
out=''
|
||||
# TODO write a ruby extension that does a good popen :P
|
||||
IO.popen "#{full} 2>&1" do |f|
|
||||
until f.eof?
|
||||
out+=f.gets
|
||||
end
|
||||
rd, wr = IO.pipe
|
||||
fork do
|
||||
rd.close
|
||||
$stdout.reopen wr
|
||||
$stderr.reopen wr
|
||||
exec cmd, *args
|
||||
end
|
||||
unless $? == 0
|
||||
puts "Exit code: #{$?}"
|
||||
out = ''
|
||||
ignore_interrupts do
|
||||
wr.close
|
||||
out << rd.read until rd.eof?
|
||||
end
|
||||
unless $?.success?
|
||||
puts out
|
||||
raise
|
||||
end
|
||||
|
||||
@ -2,13 +2,6 @@ require 'beer_events'
|
||||
require 'formula'
|
||||
require 'set'
|
||||
|
||||
def ignore_interrupts
|
||||
std_trap = trap("INT") {}
|
||||
yield
|
||||
ensure
|
||||
trap("INT", std_trap)
|
||||
end
|
||||
|
||||
class FormulaInstaller
|
||||
@@attempted = Set.new
|
||||
|
||||
|
||||
@ -150,3 +150,10 @@ def inreplace path, before, after
|
||||
f.reopen(path, 'w').write(o)
|
||||
f.close
|
||||
end
|
||||
|
||||
def ignore_interrupts
|
||||
std_trap = trap("INT") {}
|
||||
yield
|
||||
ensure
|
||||
trap("INT", std_trap)
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user