Reduce effective scope of pipe variables
This commit is contained in:
parent
659896fda2
commit
479ad0265b
@ -493,8 +493,6 @@ class Formula
|
|||||||
# Pretty titles the command and buffers stdout/stderr
|
# Pretty titles the command and buffers stdout/stderr
|
||||||
# Throws if there's an error
|
# Throws if there's an error
|
||||||
def system cmd, *args
|
def system cmd, *args
|
||||||
rd, wr = IO.pipe
|
|
||||||
|
|
||||||
# remove "boring" arguments so that the important ones are more likely to
|
# remove "boring" arguments so that the important ones are more likely to
|
||||||
# be shown considering that we trim long ohai lines to the terminal width
|
# be shown considering that we trim long ohai lines to the terminal width
|
||||||
pretty_args = args.dup
|
pretty_args = args.dup
|
||||||
@ -510,39 +508,43 @@ class Formula
|
|||||||
logfn = "#{logd}/%02d.%s" % [@exec_count, File.basename(cmd).split(' ').first]
|
logfn = "#{logd}/%02d.%s" % [@exec_count, File.basename(cmd).split(' ').first]
|
||||||
mkdir_p(logd)
|
mkdir_p(logd)
|
||||||
|
|
||||||
pid = fork { exec_cmd(cmd, args, rd, wr, logfn) }
|
rd, wr = IO.pipe
|
||||||
wr.close
|
|
||||||
|
|
||||||
File.open(logfn, 'w') do |f|
|
begin
|
||||||
f.puts Time.now, "", cmd, args, ""
|
pid = fork { exec_cmd(cmd, args, rd, wr, logfn) }
|
||||||
|
wr.close
|
||||||
|
|
||||||
if ARGV.verbose?
|
File.open(logfn, 'w') do |f|
|
||||||
while buf = rd.gets
|
f.puts Time.now, "", cmd, args, ""
|
||||||
f.puts buf
|
|
||||||
puts buf
|
if ARGV.verbose?
|
||||||
|
while buf = rd.gets
|
||||||
|
f.puts buf
|
||||||
|
puts buf
|
||||||
|
end
|
||||||
|
elsif IO.respond_to?(:copy_stream)
|
||||||
|
IO.copy_stream(rd, f)
|
||||||
|
else
|
||||||
|
buf = ""
|
||||||
|
f.write(buf) while rd.read(1024, buf)
|
||||||
|
end
|
||||||
|
|
||||||
|
Process.wait(pid)
|
||||||
|
|
||||||
|
$stdout.flush
|
||||||
|
|
||||||
|
unless $?.success?
|
||||||
|
f.flush
|
||||||
|
Kernel.system "/usr/bin/tail", "-n", "5", logfn unless ARGV.verbose?
|
||||||
|
f.puts
|
||||||
|
require 'cmd/config'
|
||||||
|
Homebrew.dump_build_config(f)
|
||||||
|
raise BuildError.new(self, cmd, args)
|
||||||
end
|
end
|
||||||
elsif IO.respond_to?(:copy_stream)
|
|
||||||
IO.copy_stream(rd, f)
|
|
||||||
else
|
|
||||||
buf = ""
|
|
||||||
f.write(buf) while rd.read(1024, buf)
|
|
||||||
end
|
|
||||||
|
|
||||||
Process.wait(pid)
|
|
||||||
|
|
||||||
$stdout.flush
|
|
||||||
|
|
||||||
unless $?.success?
|
|
||||||
f.flush
|
|
||||||
Kernel.system "/usr/bin/tail", "-n", "5", logfn unless ARGV.verbose?
|
|
||||||
f.puts
|
|
||||||
require 'cmd/config'
|
|
||||||
Homebrew.dump_build_config(f)
|
|
||||||
raise BuildError.new(self, cmd, args)
|
|
||||||
end
|
end
|
||||||
|
ensure
|
||||||
|
rd.close unless rd.closed?
|
||||||
end
|
end
|
||||||
ensure
|
|
||||||
rd.close unless rd.closed?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user