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