S
Shea Martin
<snip>
if ARGV.size > 0
puts "first arg is #{ARGV[0]}"
end
puts "enter text"
ans = gets
puts "you said #{ans}"
</snip>
Run this code, as ./test.rb. Then run it with an command line arg, like
"./test.rb -x". And you will get an error like this:
"test.rb:3:in `gets': No such file or directory - -x (Errno::ENOENT)"
The fix I have found, is to change gets to $stdin.gets. I saw some
traffic on the mailing list archives regarding this, but no resolution.
Is this expected behaviour?
ruby -v is: ruby 1.8.3 (2005-09-21) [sparc-solaris2.10]
Thanks,
~S
if ARGV.size > 0
puts "first arg is #{ARGV[0]}"
end
puts "enter text"
ans = gets
puts "you said #{ans}"
</snip>
Run this code, as ./test.rb. Then run it with an command line arg, like
"./test.rb -x". And you will get an error like this:
"test.rb:3:in `gets': No such file or directory - -x (Errno::ENOENT)"
The fix I have found, is to change gets to $stdin.gets. I saw some
traffic on the mailing list archives regarding this, but no resolution.
Is this expected behaviour?
ruby -v is: ruby 1.8.3 (2005-09-21) [sparc-solaris2.10]
Thanks,
~S