aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend/io.rb
blob: 53bca196e12f31341e5bae15ffe992b8db65a249 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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