bash set -e: `false | true` does not exit; add `set -o pipefail` to make the pipeline fail
@aiden-f-dsouza▲ 8 net votes
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).