cmd/lib/capture: fix RuboCop style.

See https://github.com/Homebrew/brew/pull/7867.
This commit is contained in:
Mike McQuaid 2020-07-27 10:39:12 +01:00
parent 155c848ddf
commit 65de0eb647
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
1 changed files with 10 additions and 14 deletions

View File

@ -9,28 +9,24 @@ def capture
$stderr.reopen(w)
thread = Thread.new do
begin
yield
ensure
w.close
end
yield
ensure
w.close
end
thread.abort_on_exception = true
output = ""
loop do
begin
selected = IO.select([r], [], [], 1)
selected = IO.select([r], [], [], 1)
if reader = selected&.dig(0, 0)
output << (reader.readline_nonblock || "")
else
break if w.closed?
end
rescue IO::WaitReadable
retry
if (reader = selected&.dig(0, 0))
output << (reader.readline_nonblock || "")
elsif w.closed?
break
end
rescue IO::WaitReadable
retry
end
result = thread.value