From: Stefan Lang Date: 2005-06-07T04:36:50+09:00 Subject: Re: 'gets' has been hijacked On Monday 06 June 2005 21:31, Pete Elmore wrote: > I was working with a simple script, that unexpectedly broke. The > problem can be reduced to this: > > pete@robots:~$ cat t.rb > #!/usr/bin/env ruby > p gets > pete@robots:~$ ./t.rb > asdf > "asdf\n" > pete@robots:~$ ./t.rb nonexistent-file > ./t.rb:2:in `gets': No such file or directory - nonexistent-file > (Errno::ENOENT) > from ./t.rb:2 > > Ah, right, I remember this from the Bad Old Days of Perl: stdin has been > stolen. Is there any way to stop this behavior, like a global I could > set or a flag I could pass to ruby? Couldn't find anything on the man > page or in Pickaxe. You could explicitely call #readline on $stdin instead of Kernel#gets: $stdin.readline Stefan