My ruby script gets certain inputs from command line arguments. It check if any of the command line argument is missing, then it prompts for an input from user. But i am not
gets
will only read from the real $stdin
(ie the user) if there are no command line arguments. Otherwise it'll take those arguments as files to concatenate as a virtual $stdin
.
You can use STDIN.gets
to make sure you're always using the right function.
You can also delete the arguments from ARGV
as you go (or remove them all in one go), your gets
should work correctly.