Gary Wright
9/27/2006 8:50:00 PM
On Sep 27, 2006, at 4:27 PM, greg wrote:
> thanks, a
>
> This kind of sucks though.
>
> apparently in perl, if there is a piped input, '-' will show up
> automatically in ARGV. I think I will propose this change to Ruby.
Normally I would just nod my head in agreement with Ara, but not this
time.
I just have to say yuck with regard to using '-' and the idea that
command lines
should have have an explicit syntax to indicate that the program
should read from
stdin.
If your program is prepared to deal with piped input, why are
you concerned about input coming from the keyboard? If I found a
program
that worked as:
cat file | program
and as
program < file
but did not work as just
program
I would be surprised, to say the least.
Usually the issue is the other way around where an interactive
program (vim, for
example) *needs* a tty device on stdin and may complain when
STDIN.tty? fails, but
I'm not sure I understand the need to complain about STDIN being tied
to a tty device
for a program that is just reading a stream of data.
The '-' hack just makes me shudder. Something like '/dev/stdin'
would be marginally better
if you really need something like that (although not as portable).