Shell scripts - getting parent status in read
T. William Wells
bill at twwells.uucp
Wed Apr 26 13:38:53 AEST 1989
In article <866 at marvin.Solbourne.COM> dce at Solbourne.com (David Elliott) writes:
: In article <849 at twwells.uucp> bill at twwells.UUCP (T. William Wells) writes:
: >[something stupid].
:
: Are you sure about this?
No. I have no idea what drugs I had been slipped when I wrote that. Or
maybe it's lack of sleep? :-)
: I would think this would cause an EOF, and there was some
: discussion on this recently, but it doesn't.
So would I. And, in fact it does. The problem is that the shell
doesn't exit on EOF. I just tested this on my V/386 3.0 Bourne shell.
I wrote a little shell:
while true
do
read foo
echo "<$foo>"
done
to see what happens. And what happens is that EOF and newline both
set foo to a null string.
HEY! I just RTFM. According to it, you get a return status from read!
Adding:
echo $?
before the other echo, I get 0 on a blank line, 1 on EOF.
When I feed data through a pipe, it works as expected.
(I feel better now I can wipe the egg off my face.)
---
Bill { uunet | novavax } !twwells!bill
More information about the Comp.unix.wizards
mailing list