bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pipefail bug


From: John Kelly
Subject: Re: pipefail bug
Date: Mon, 04 Dec 2006 17:22:51 +0000

On Mon, 04 Dec 2006 11:53:03 -0500, Chet Ramey <chet.ramey@case.edu>
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.






reply via email to

[Prev in Thread] Current Thread [Next in Thread]