set -o pipefail
- BASH normally only looks at the exit code of the last command of a pipeline
- This behavior is not ideal as it causes the -e option to only be able to act on the exit code of a pipeline’s last command
- This particular option sets the exit code of a pipeline to that of the rightmost command to exit with a non-zero status, or to zero if all commands of the pipeline exit successfully.
#### Without Pipefail
bash ./examples/options/options_without_pipefail.sh
echo $?
#### With Pipefail
bash ./examples/options/options_with_pipefail.sh
echo $?
### References