Hello!
I'd really appreciate if someone could shed some light on this issue.
Please consider the following script:
#!/usr/bin/ksh
while true; do
/bin/echo "test" > /tmp/file | head
if [ ! -s /tmp/file ]; then
echo; exit
else
echo -n "."
fi
done
While I understand that there is a "mistake" in the script and head(1) will
never receive any input, I can't explain why /tmp/file is sometimes empty when
the test is evaluated:
$ ./scr
................................................
$ ./scr
.....................................................
$ ./scr
...................
$ ./scr
...........................
$ ./scr
...
Could it be that:
1) The shell forks twice to execute '/bin/echo "test" > /tmp/file | head'
2) head(1) runs first, reads from "null" and immediately exits
3) SIGCHLD is delivered to the shell
4) The shell runs 'if [ ! -s /tmp/file ] ..' which evaluates to true
5) exit() is called and /bin/echo runs or /bin/echo runs and exit()
is called (order doesn't matter).
Is this a bug or the expected behavior?
When running the same script in bash or pdksh, the test is always false
(ie, the script never exits).
Thanks!
Leonardo
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers