On Tue, Jun 25, 2024 at 4:05 AM Martin D Kealey <mar...@kurahaupo.gen.nz> wrote:
> • Normally it's expected that if any part of a pipeline exits, all
> preceding parts would eventually receive SIGPIPE upon writing to stdout.

To expand on this a bit, when a process exits because of receiving a
signal like SIGPIPE, it will exit with an exit code of 128 + the
signal number. Thus, in a situation where everything in the pipeline
actually worked correctly, it's still possible that some parts of the
pipeline will exit with a nonzero exit status, which bash would take
as indicating failure in this scenario. Nothing in bash makes a
distinction between a process exiting with the SIGPIPE exit code and
any other potential nonzero exit code. This is part of why 'set -euo
pipefail' is not a great idea.[1]

[1]: https://mywiki.wooledge.org/BashPitfalls?highlight=%28pipefail%29#pipefail

Reply via email to