Skip to content

Commit

Permalink
Catching nil response from readline which indicates an EOF
Browse files Browse the repository at this point in the history
  • Loading branch information
mleinart committed Jan 3, 2011
1 parent 52744e8 commit 93d01cf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/highline.rb
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,16 @@ def get_line( )
# work-around ugly readline() warnings
old_verbose = $VERBOSE
$VERBOSE = nil
raw_answer = Readline.readline(question, true)
if raw_answer.nil?
if @@track_eof
raise EOFError, "The input stream is exhausted."
else
raw_answer = String.new # Never return nil
end
end
answer = @question.change_case(
@question.remove_whitespace(
Readline.readline(question, true) ) )
@question.remove_whitespace(raw_answer))
$VERBOSE = old_verbose

answer
Expand Down

0 comments on commit 93d01cf

Please sign in to comment.