From: Tom Cloyd [mailto:tomcloyd / comcast.net]
# I'm playing with various ways of using readline, like
#
# require 'readline'
# puts 'test under way'
# opt = readline( "=--> \n")
# puts( opt)
#
# Nothing works, so far. The code above seems to stop at line
# 2. Or maybe it's 3, but there's no prompt output.
# We surely never get to line 4.
that is because, the line
opt = readline( "=--> \n") will call ruby's Kernel.readline and not readline's readline (if i may say that ;-). So, what is happening is that ruby will treat "=--> \n" not as a prompt, but as your input ender, ergo it is waiting for the string "=--> \n" wc you never type obviously.
you really want
opt = Readline::readline( "=--> \n")
Eg,
botp@pc4all:~$ cat test.rb
require 'readline'
puts 'test under way'
opt = Readline::readline( "=-->\n")
puts( opt)
botp@pc4all:~$ ruby test.rb
test under way
=-->
is this ok?
is this ok?
botp@pc4all:~$
kind regards -botp