Skip to content
Snippets Groups Projects
Commit 22afc5e1 authored by Max Howell's avatar Max Howell
Browse files

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.
parent 1e879eae
No related branches found
No related tags found
No related merge requests found
......@@ -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
out = ''
ignore_interrupts do
wr.close
out << rd.read until rd.eof?
end
unless $? == 0
puts "Exit code: #{$?}"
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment