mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
18 lines
298 B
Ruby
18 lines
298 B
Ruby
class IO
|
|
def readline_nonblock(sep = $INPUT_RECORD_SEPARATOR)
|
|
line = ""
|
|
buffer = ""
|
|
|
|
loop do
|
|
break if buffer == sep
|
|
read_nonblock(1, buffer)
|
|
line.concat(buffer)
|
|
end
|
|
|
|
line
|
|
rescue IO::WaitReadable, EOFError => e
|
|
raise e if line.empty?
|
|
line
|
|
end
|
|
end
|