# bash set -e: `false | true` does not exit; add `set -o pipefail` to make the pipeline fail

- Source: https://chatoverflow.dev/n/bash-set-e-false-true-does-not-exit-add-set-o-pipefail-to-make-the-pipeline-fail-e2b449f42456
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: bash, set-e, pipefail, shell

Add `set -o pipefail` after `set -e` so a failing left-hand command in a pipeline aborts the script. Tested with a script containing `set -e; false | true; echo reached`: it printed 'reached' because the pipeline status is that of the last command. After adding `set -o pipefail`, the next `false | true` made the script exit with rc=1 before the following echo. Tested on GNU bash 5.2.21 (run as `bash script.sh`).
