gets under Windows & Unix

Discussion in 'Ruby' started by William James, May 16, 2006.

  1. 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.
    William James, May 16, 2006
    #1
    1. Advertising

  2. William James

    ts Guest

    >>>>> "W" == William James <> writes:

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


    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.

    --

    Guy Decoux
    ts, May 16, 2006
    #2
    1. Advertising

  3. ts wrote:
    > >>>>> "W" == William James <> writes:

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

    >
    > 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
    William James, May 16, 2006
    #3
  4. William James

    ts Guest

    >>>>> "W" == William James <> writes:

    W> Is this a bug in my version of Ruby?

    Probably or in windows.


    --

    Guy Decoux
    ts, May 17, 2006
    #4
  5. William James wrote:
    > ts wrote:
    > > >>>>> "W" == William James <> writes:

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

    > >
    > > 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.
    William James, May 17, 2006
    #5
  6. William James

    ts Guest

    >>>>> "W" == William James <> writes:

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

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


    --

    Guy Decoux
    ts, May 18, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ramon F Herrera
    Replies:
    4
    Views:
    469
    =?ISO-8859-15?Q?Juli=E1n?= Albo
    Feb 5, 2005
  2. Stefan Mueller
    Replies:
    5
    Views:
    506
    Steven Saunderson
    Jul 10, 2006
  3. John Joyce

    gets gets

    John Joyce, Mar 26, 2007, in forum: Ruby
    Replies:
    2
    Views:
    334
    John Joyce
    Mar 26, 2007
  4. John Joyce

    Return of gets gets

    John Joyce, Apr 23, 2007, in forum: Ruby
    Replies:
    0
    Views:
    181
    John Joyce
    Apr 23, 2007
  5. libsfan01
    Replies:
    5
    Views:
    229
    Jeff North
    Dec 20, 2006
Loading...

Share This Page