Usually you don't notice the difference simply because if ARGV doesn't exist Kernel#gets simply reads from stdin. However, tonight I started building out some of the scm wrapper functionality of widi and naturally I was adding command line arguments. This caused widi to die a painful death. It's last words were:
kill #: widi.rb:27:in `gets': No such file or directory - kill (Errno::ENOENT)
from widi.rb:27
To fix the problem I googled a bit and realized I needed to explicitly tell ruby to check stdin using the global variable $stdin (IO#gets is private so don't even bother trying to call it!). Not exactly intuitive but I guess I can't complain too much.
No comments:
Post a Comment