W
Wybo Dekker
I'm translating a Perl script into Ruby, but can't reproduce a readline
action. I made two, hopefully equivalent, test scripts in Perl and Ruby,
but they behave differently.
Here's my Perl script:
#!/usr/bin/perl
use Term::ReadLine;
# count lines in stdin (the mail message):
$n=0; while (<>) { $n++ }
print "$n lines\n";
my $term=new Term::ReadLine 'vpp';
$term->readline("type return to quit: ")
And here the test run:
$ echo test |readlineperl
1 lines
type return to quit:
$
Now the Ruby version:
#!/usr/bin/env ruby
require 'readline'
include Readline
# count lines in stdin (the mail message):
n=0; while gets: n+=1 end
puts "#{n} lines"
readline("type return to quit: ")
Its test run does not exit with a return - it needs ctrl-C:
$ echo test |readlineruby
1 lines
type return to quit:
./readlineruby:10:in `readline': Interrupt
from ./readlineruby:10
$
Is this a bug? Or a missing feature, like Readline.new?
action. I made two, hopefully equivalent, test scripts in Perl and Ruby,
but they behave differently.
Here's my Perl script:
#!/usr/bin/perl
use Term::ReadLine;
# count lines in stdin (the mail message):
$n=0; while (<>) { $n++ }
print "$n lines\n";
my $term=new Term::ReadLine 'vpp';
$term->readline("type return to quit: ")
And here the test run:
$ echo test |readlineperl
1 lines
type return to quit:
$
Now the Ruby version:
#!/usr/bin/env ruby
require 'readline'
include Readline
# count lines in stdin (the mail message):
n=0; while gets: n+=1 end
puts "#{n} lines"
readline("type return to quit: ")
Its test run does not exit with a return - it needs ctrl-C:
$ echo test |readlineruby
1 lines
type return to quit:
./readlineruby:10:in `readline': Interrupt
from ./readlineruby:10
$
Is this a bug? Or a missing feature, like Readline.new?