Tom Lord <[EMAIL PROTECTED]> wrote: > Exit status of non-leading programs in pipelines is a weak spot of > shell programming.
Non-trailing, you mean? > Using the notation "|+" for this, one might write: > > set -e > > sort "$somefile" |+ head -1 > ,first-one > > expecting the script to fail if "$somefile" can not be opened or > the `sort' fails for some other reason. > > But what if `sort' will die of a SIGPIPE? FWIW, it's easy enough to prevent that in the script, by making sure the later programs in the pipeline read stdin all the way to EOF. sort "$somefile" |+ sed -n 1p > ,first-one > Consider that `sort' may get SIGPIPE or EPIPE for two very distinct > reasons. (1) it might get that error because the consumer for its > stdout has stopped reading. This is an ordinary and expected > condition and means only that `sort' is free to exit at will. That would not be true in a situation where the reading end of the pipe is closed as a result of an error, and the error is otherwise not reported - or at least, not sufficently reported. How sure are we that that can never happen? paul _______________________________________________ Bug-textutils mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-textutils