From b45996dada3e45a70ee901ff944e3aa8c146ebfa Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Thu, 14 Jun 2018 22:12:19 +0200 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20use=20`ohai`=20for=20`SystemCom?= =?UTF-8?q?mand`=20output.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Homebrew/cask/lib/hbc/system_command.rb | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Library/Homebrew/cask/lib/hbc/system_command.rb b/Library/Homebrew/cask/lib/hbc/system_command.rb index e5a7d9202b..0c6f0eb367 100644 --- a/Library/Homebrew/cask/lib/hbc/system_command.rb +++ b/Library/Homebrew/cask/lib/hbc/system_command.rb @@ -25,11 +25,11 @@ module Hbc each_output_line do |type, line| case type when :stdout + puts line.chomp if print_stdout? processed_output[:stdout] << line - ohai line.chomp if print_stdout? when :stderr + $stderr.puts Formatter.error(line.chomp) if print_stderr? processed_output[:stderr] << line - ohai line.chomp if print_stderr? end end @@ -100,17 +100,23 @@ module Hbc def each_line_from(sources) loop do - readable_sources = IO.select(sources)[0] - readable_sources.delete_if(&:eof?).first(1).each do |source| - type = ((source == sources[0]) ? :stdout : :stderr) + readable_sources, = IO.select(sources) + + readable_sources = readable_sources.reject(&:eof?) + + break if readable_sources.empty? + + readable_sources.each do |source| begin - yield(type, source.readline_nonblock || "") + line = source.readline_nonblock || "" + type = (source == sources[0]) ? :stdout : :stderr + yield(type, line) rescue IO::WaitReadable, EOFError next end end - break if readable_sources.empty? end + sources.each(&:close_read) end