bug-bash
[Top][All Lists]
Advanced

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

Re: errexit is not suspended in a pipeline


From: Quinn Grier
Subject: Re: errexit is not suspended in a pipeline
Date: Wed, 11 Jan 2023 20:22:23 -0800
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1

On 2023-01-11 13:20, Chet Ramey wrote:
They are not all contexts where set -e is ignored. There is a distinction
between the effect of -e being ignored and the shell not exiting when a
command fails.

If you don't like the bash manual page wording, here's what POSIX says:

"1.    The failure of any individual command in a multi-command pipeline
shall not cause the shell to exit. Only the failure of the pipeline itself
shall be considered.

2.    The -e setting shall be ignored when executing the compound list
following the while, until, if, or elif reserved word, a pipeline beginning
with the ! reserved word, or any command of an AND-OR list other than the last.

3.    If the exit status of a compound command other than a subshell
command was the result of a failure while -e was being ignored, then -e
shall not apply to this command.

I see. I had mistakenly thought that Bash's set -e description was
definitively listing the contexts in which set -e is ignored, not just
contexts in which set -e may not have the intended effect. Really it's
POSIX that definitively lists the contexts in which set -e is ignored,
as you explain above.

The lists are almost the same, with the only difference being that Bash
also lists "any command in a pipeline but the last". This is a context
in which set -e is *not* ignored but may also not have the intended
effect, as the pipeline ignores the exit statuses of all non-last
commands (except if set -o pipefail is being used).

Thank you for clearing this up for me.



reply via email to

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