gets under Windows & Unix

W

William James

ruby -ne 'print; gets if ARGF.eof' file*

The object is to print line 1 from file 1 and lines 2 through last
from every file.

A perl user alleged that under Unix:
That will print out the file contents and then wait for more input from stdin
so you have to follow it with ^D to signal EOF.

Not having access to a Unix or Linux system, I would be grateful
if someone would test this.
 
T

ts

W> A perl user alleged that under Unix:

no, no : it don't wait for more input from stdin.

it read from stdin *only* if you don't give argument to the command.
 
W

William James

ts said:
W> A perl user alleged that under Unix:


no, no : it don't wait for more input from stdin.

it read from stdin *only* if you don't give argument to the command.


Yes, this is the way it works on my windows 2000 computer.
However, I just tested it on a windows xp computer. After printing
the files, it attempts to read from stdin and I have to press ^Z !

The code in question is
ruby -ne 'print; gets if ARGF.eof' file*

My Ruby version on the xp box is ruby 1.8.2 (2004-05-19)
[i386-mswin32].

Is this a bug in my version of Ruby?
 
W

William James

William said:
ts said:
W> A perl user alleged that under Unix:


no, no : it don't wait for more input from stdin.

it read from stdin *only* if you don't give argument to the command.


Yes, this is the way it works on my windows 2000 computer.
However, I just tested it on a windows xp computer. After printing
the files, it attempts to read from stdin and I have to press ^Z !

The code in question is
ruby -ne 'print; gets if ARGF.eof' file*

My Ruby version on the xp box is ruby 1.8.2 (2004-05-19)
[i386-mswin32].

Is this a bug in my version of Ruby?


Guy Decoux wrote
W> Is this a bug in my version of Ruby?
Probably or in windows.


And apparently this same bug exists in a version of Ruby
running under Unix or Linux, because the Perl-user said
he had to press ^D.

It is pitiful that Ruby can't even execute "gets" properly.
 
T

ts

W> It is pitiful that Ruby can't even execute "gets" properly.

ruby just work fine, this is the P language which is buggy :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top