On Mon, 04 Dec 2006 11:53:03 -0500, Chet Ramey <[EMAIL PROTECTED]>
wrote:

>> # With -e -o pipefail, this script should exit immediately upon returning
>> # from the pipeline, since grep does not match its string, and returns 1.

>This is not true, strictly speaking.  The `-e' option applies to only
>simple commands.  Bash does make `-e' apply to pipelines whose last
>element is a simple command, but only for compatibility with historical
>shell implementations.  That accounts for the apparent anomaly.
>
>Posix is not exactly clear on this topic, but I believe bash's
>interpretation is conformant.

I suppose it's debatable whether it should be "fixed" or not.

Nevertheless, it's a snare for unwary script writers who expect their
script to exit on pipe errors when -e -o pipefail is set.  It's fairly
common for a pipe to end with a "while read" loop, which triggers the
anomalous behavior.

Maybe the behavior should be documented somewhere, with the suggested
work around.




_______________________________________________
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash

Reply via email to