Ralph Corderoy <ralph(_at_)inputplus(_dot_)co(_dot_)uk> writes:
Hi Norm,
Confession: I have never fixed this problem:
false|true
Then true is run and the command does not return an error value.
Yes, the traditional exit status of a pipe is that of its last command.
bash has a pipefail shell option.
The return status of a pipeline is the exit status of the last
command, unless the pipefail option is enabled. If pipefail is
enabled, the pipeline's return status is the value of the last
(rightmost) command to exit with a non-zero status, or zero if all
commands exit successfully. If the reserved word ! precedes a
pipeline, the exit status of that pipeline is the logical negation
of the exit status as described above. The shell waits for all
commands in the pipeline to terminate before returning a value.
Thank you. I was unaware of that feature. I will try it on new scripts, though
I'm too cowardly to try it on existing scripts.
But even with that:
false|rm -rf /
run as root would not be wise.:-)
That is, a whole pipeline will be run, even if a non-rightmost command exits
with an error return status.
Norman Shapiro
_______________________________________________
Nmh-workers mailing list
Nmh-workers(_at_)nongnu(_dot_)org
https://lists.nongnu.org/mailman/listinfo/nmh-workers