Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

gnu readline ruby vs. perl

1 view
Skip to first unread message

Wybo Dekker

unread,
Jun 9, 2005, 6:19:45 PM6/9/05
to
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?

--
Wybo


Yukihiro Matsumoto

unread,
Jun 9, 2005, 7:42:52 PM6/9/05
to
Hi,

In message "Re: gnu readline ruby vs. perl"


on Fri, 10 Jun 2005 07:19:45 +0900, Wybo Dekker <wy...@servalys.nl> writes:

|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.

Ruby's readline takes input from stdin. Perhaps Perls takes from
/dev/tty, or something. Any information is welcome.

matz.


nobuyoshi nakada

unread,
Jun 9, 2005, 10:22:26 PM6/9/05
to
Hi,

At Fri, 10 Jun 2005 07:19:45 +0900,
Wybo Dekker wrote in [ruby-talk:145011]:


> 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
> $

The test exited immediately after printing the prompt, on my box.
What are your platform, ruby and readline versions?

--
Nobu Nakada


Gyoung-Yoon Noh

unread,
Jun 9, 2005, 11:35:35 PM6/9/05
to
On 6/10/05, nobuyoshi nakada <nobuyosh...@ge.com> wrote:
> The test exited immediately after printing the prompt, on my box.
> What are your platform, ruby and readline versions?
>

I've experienced same problem with OP.

$ ldd /usr/lib/ruby/1.8/i686-linux/readline.so | grep readline
libreadline.so.4 => /lib/libreadline.so.4 (0xb7f00000)
$ ruby -v
ruby 1.8.2 (2004-12-25) [i686-linux]

Same on the 1.9 (March).

--
http://nohmad.sub-port.net


Wybo Dekker

unread,
Jun 12, 2005, 7:57:04 AM6/12/05
to
> Gyoung-Yoon Noh wrote on Fri, 10 Jun 2005 12:35:35 +0900:

>
> On 6/10/05, nobuyoshi nakada <nobuyoshi.nakada ge.com> wrote:
> > The test exited immediately after printing the prompt, on my box.
> > What are your platform, ruby and readline versions?
> >
>
> I've experienced same problem with OP.
>
> $ ldd /usr/lib/ruby/1.8/i686-linux/readline.so | grep readline
> libreadline.so.4 => /lib/libreadline.so.4 (0xb7f00000)
> $ ruby -v
> ruby 1.8.2 (2004-12-25) [i686-linux]
>
> Same on the 1.9 (March).

I had the same, both on ruby 1.8 and 1.9, but with libreadline.so.5

--
Wybo


nobu....@softhome.net

unread,
Jun 12, 2005, 9:41:21 AM6/12/05
to
Hi,

At Sun, 12 Jun 2005 20:57:04 +0900,
Wybo Dekker wrote in [ruby-talk:145200]:


> > > The test exited immediately after printing the prompt, on my box.
> > > What are your platform, ruby and readline versions?

This was on cygwin.

> > I've experienced same problem with OP.
> >
> > $ ldd /usr/lib/ruby/1.8/i686-linux/readline.so | grep readline
> > libreadline.so.4 => /lib/libreadline.so.4 (0xb7f00000)
> > $ ruby -v
> > ruby 1.8.2 (2004-12-25) [i686-linux]
> >
> > Same on the 1.9 (March).
>
> I had the same, both on ruby 1.8 and 1.9, but with libreadline.so.5

Same on linux.

Seems depending on readline implementation.

--
Nobu Nakada


men...@rydia.net

unread,
Dec 16, 2005, 1:16:35 PM12/16/05
to
Quoting nobuyoshi nakada <nobuyosh...@ge.com>:

> > Somehow a file contains sequence number corrupted on 2005-12-15
> > 19:27:58 JST. I just restored.
>
> Old articles 1-112 were lost? Seems blade has lost them too.

Ugh... probably because they were "overwritten" by the mis-numbered
articles.

Hopefully someone has backups... I imagine they are rather
historically important...

-mental


gwt...@mac.com

unread,
Dec 16, 2005, 2:20:11 PM12/16/05
to

On Dec 16, 2005, at 1:16 PM, men...@rydia.net wrote:

> Quoting nobuyoshi nakada <nobuyosh...@ge.com>:
>
>>> Somehow a file contains sequence number corrupted on 2005-12-15
>>> 19:27:58 JST. I just restored.
>>
>> Old articles 1-112 were lost? Seems blade has lost them too.
>

> Hopefully someone has backups... I imagine they are rather
> historically important...

for the moment they are in the google cache...

Wayne Vucenic

unread,
Dec 16, 2005, 3:02:42 PM12/16/05
to

I should have backups of all these articles. I can check when I get
home tonight.

Wayne

---
Wayne Vucenic
No Bugs Software
"Ruby and C++ Agile Contract Programming in Silicon Valley"


Christian Neukirchen

unread,
Dec 16, 2005, 6:15:51 PM12/16/05
to
men...@rydia.net writes:

> Quoting nobuyoshi nakada <nobuyosh...@ge.com>:
>
>> > Somehow a file contains sequence number corrupted on 2005-12-15
>> > 19:27:58 JST. I just restored.
>>
>> Old articles 1-112 were lost? Seems blade has lost them too.
>
> Ugh... probably because they were "overwritten" by the mis-numbered
> articles.

oO(can this be exploited by faking the X-Mail-Count number?)

> Hopefully someone has backups... I imagine they are rather
> historically important...
>
> -mental

--
Christian Neukirchen <chneuk...@gmail.com> http://chneukirchen.org


men...@rydia.net

unread,
Dec 16, 2005, 6:36:11 PM12/16/05
to
So long as this message doesn't have a Mail-Count of 10101010, we're OK.


men...@rydia.net

unread,
Dec 16, 2005, 6:39:04 PM12/16/05
to
Quoting men...@rydia.net:

> So long as this message doesn't have a Mail-Count of 10101010,
> we're OK.

Hmm. Now it's got TWO X-Mail-Count headers. That's not good.

Is there a reason for the listserv to preserve existing mail-count
headers?

-mental

men...@rydia.net

unread,
Dec 16, 2005, 6:41:40 PM12/16/05
to
Quoting Christian Neukirchen <chneuk...@gmail.com>:

> .oO(can this be exploited by faking the X-Mail-Count number?)

Possibly... it looks like the listserv doesn't strip existing
X-Mail-Counts, though it puts them second.

-mental


men...@rydia.net

unread,
Dec 16, 2005, 6:47:55 PM12/16/05
to
Quoting men...@rydia.net:

(the archives are okay, since they ignore all but the first)

-mental


Wayne Vucenic

unread,
Dec 16, 2005, 11:54:18 PM12/16/05
to
I do have backups of all these files, as .htm files that I used 'net/http'
to get from http://www.ruby-talk.org/cgi-bin/scat.rb/ruby/ruby-talk/nnn.

If anyone needs them to do the restore, I'll .zip them up and send them
to you.

Wayne

0 new messages