[Top][All Lists]

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

Re: Error in pipeline ignored when not in last command

From: Paul Jarc
Subject: Re: Error in pipeline ignored when not in last command
Date: Sat, 07 Feb 2004 00:35:21 -0500
User-agent: Gnus/5.110002 (No Gnus v0.2) Emacs/21.3 (gnu/linux)

address@hidden wrote:
>    When a command ends with a non-zero status, and this is not the
>    last command in a pipeline, 'set -e' does not cause the script to
>    be aborted.

This is normal, and code like "very-verbose-command | head" depends on
it.  (head exits before reading all of its input; very-verbose-command
dies from SIGPIPE when it tries to write to the closed pipe.)

>    The documented behavior seems to be more useful than the implemented
>    behavior: "set -e" is a good quick&dirty way to make sure that in case
>    something goes wrong the script will stop before doing any harm, and
>    errors in pipeline are often relevant.

It may have been useful if it had been implemented that way
originally, but now the current behavior is far too well entrenched to
dislodge it.  In practice, and especially when writing portable shell
scripts, set -e is not nearly as useful as we would like it to be.

If the documentation does not describe this behavior adequately, then
that's a documentation bug; it'd be up to the bash maintainer to fix


reply via email to

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