Ross Bamford
5/3/2006 11:27:00 AM
On Tue, 02 May 2006 20:32:19 +0100, itsme213 <itsme213@hotmail.com> wrote:
>
> "Ross Bamford" <rosco@roscopeco.remove.co.uk> wrote in message
>> Kernel#gets behaves differently in different situations (it basically
>> reads ARGF which may or may not be stdin - here it's a file 'foo'. See
>> docs for more details). I find it's usually best (especially in embedded
>> ruby, such as a Rakefile) to go for an explicit $stdin.gets. Try switch
>> ing the input line for:
>>
>> i = $stdin.gets.to_i
>>
>> Hope that helps,
>
> It does fix this failure, thanks a bunch!
>
> (though I don't believe rake should make it think it's reading a file
> 'foo')
>
It's not a rake-specific thing, it's just the way Kernel#gets works in
ruby:
$ ruby -e 'puts gets'
No filename given, I had to type this in
No filename given, I had to type this in
$ ruby -e 'puts gets' index.html
<?xml version="1.0" encoding="iso-8859-1"?>
The reason I mentioned embedded usage is because often you have no control
over how the commandline is used there, so gets can seem to behave quite
arbitrarily since you can't see what's actually happening.
--
Ross Bamford - rosco@roscopeco.remove.co.uk