I am first taking multiline input from user. User may end input using
Ctr-d.

Then I use highline's menu and get:
/opt/local/lib/ruby1.9/gems/1.9.1/gems/highline-1.5.2/lib/highline.rb:603:in
`get_line': The input stream is exhausted. (EOFError)

However, experimentally, if I end multiline input on user entering
"bye", then highline works, but with Ctrl-D it bombs.

How can i clear EOF prior to calling highline.  I tried:

    HighLine.track_eof = false

but it pushes the error further (split on nil).

I've tried reopening stdin with a $stdin.reopen '/dev/tty' but it makes
no difference.

My earlier code is:

  def get_lines
    lines = nil
    #$stdin.flush
    $stdin.each_line do |line|
      line.chomp!
      if line =~ /^bye$/
        break
      end
      if lines
        lines << "\n" + line
      else
        lines = line
      end
    end
    return lines
  end

After calling get_lines, I call this method:

  def _choice prompt, choices
    #HighLine.track_eof = false
    puts "got: #{prompt} ::: #{choices} "
    #$stdin.flush
    STDIN.reopen '/dev/tty'
    choose do |menu|
      menu.prompt = prompt
      menu.choices(choices) do |n|  return n; end
    end
  end
-- 
Posted via http://www.ruby-forum.com/.