bug-bash
[Top][All Lists]
Advanced

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

errexit is not suspended in a pipeline


From: Quinn Grier
Subject: errexit is not suspended in a pipeline
Date: Tue, 10 Jan 2023 18:36:27 -0800
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1

In the documentation for set -e, the Bash manual says that errexit is
suspended in all but the last command of a pipeline:

      The shell does not exit if the command that fails is part of
      [...] any command in a pipeline but the last

The documentation also of course says that errexit suspension cascades
into compound commands:

      If a compound command or shell function executes in a
      context where -e is being ignored, none of the commands
      executed within the compound command or function body will
      be affected by the -e setting, even if -e is set and a
      command returns a failure status.

This means the following script should output both "1" and "2":

      (false; echo 1) | cat
      set -e
      (false; echo 2) | cat

However, it only outputs "1". I tested in Bash 4.0 through 5.2.

Is this a bug in the behavior, or is it a bug in the documentation?




reply via email to

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