/dev/stdin
Root Boy Jim
rbj at cmr.icst.nbs.gov
Tue Jun 28 09:25:20 AEST 1988
? From: Tom Newcomb <newcomb at cory.berkeley.edu>
? So, if all you want is the TTY input, why not use /dev/tty? It's worked
? beautifully in all the cases I've tried. So, what am I missing? Can anybody
? come up with a case where /dev/stdin would NOT be /dev/tty, besides shell
? scripts? (I already know this won't work for scripts run from a shell whose
? input has been redirected.) In a C program, also, you can just do an
? fdopen(3) on descriptor 0 (and that ALWAYS works).
The point is that stdin is not always /dev/tty. And not all commands support
the (considered by some) ugly kluge of `-' == stdin.
One guy wanted to print a file, even lines in the first column, odd lines
in the second column; he tried "cat file | pr -2 - -". Unfortunately, pr
does not support `-' as a synonym for stdin. Replacing `-' by `/dev/stdin'
should produce the desired results.
Another (mis?)use is to compile programs from stdin. First, we do
`ln -s /dev/stdin x.c', then `cc -c x.c'. I'm sure one can find really
useful uses for stdin being a real file, but personally, I have never
felt enough need to install it. I'm sure the authors have better arguments.
? Tom Newcomb | WEST, v. West is what wabbits do when they
? newcomb at cory.Berkeley.EDU | get tired of wunning awound.
(Root Boy) Jim Cottrell <rbj at icst-cmr.arpa>
National Bureau of Standards
Flamer's Hotline: (301) 975-5688
The opinions expressed are solely my own
and do not reflect NBS policy or agreement
Careful with that VAX Eugene!
More information about the Comp.unix.wizards
mailing list