diff options
| author | Jack Nagel | 2014-09-05 15:13:53 -0500 |
|---|---|---|
| committer | Jack Nagel | 2014-09-05 15:13:53 -0500 |
| commit | a3409a179e3c56e6e8636441bc61e2efd765332d (patch) | |
| tree | 53e82efa1304d85073a5bc5412a5da9c62d934be /Library | |
| parent | 34ea00783c99e309157764470980d752057727e8 (diff) | |
| download | brew-a3409a179e3c56e6e8636441bc61e2efd765332d.tar.bz2 | |
Reduce branches and effective scope of some variables
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/formula.rb | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 7d8f99602..b65d56dd7 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -513,40 +513,36 @@ class Formula if ARGV.verbose? rd, wr = IO.pipe - out = wr - else - out = log - end - - begin - pid = fork do - if rd + begin + pid = fork do rd.close log.close + exec_cmd(cmd, args, wr, logfn) end - exec_cmd(cmd, args, out, logfn) - end - wr.close if wr + wr.close - while buf = rd.gets - log.puts buf - puts buf - end if rd + while buf = rd.gets + log.puts buf + puts buf + end + ensure + rd.close unless rd.closed? + end + else + pid = fork { exec_cmd(cmd, args, log, logfn) } + end - Process.wait(pid) + Process.wait(pid) - $stdout.flush + $stdout.flush - unless $?.success? - log.flush - Kernel.system "/usr/bin/tail", "-n", "5", logfn unless ARGV.verbose? - log.puts - require 'cmd/config' - Homebrew.dump_build_config(log) - raise BuildError.new(self, cmd, args) - end - ensure - rd.close if rd && !rd.closed? + unless $?.success? + log.flush + Kernel.system "/usr/bin/tail", "-n", "5", logfn unless ARGV.verbose? + log.puts + require 'cmd/config' + Homebrew.dump_build_config(log) + raise BuildError.new(self, cmd, args) end end |
