pipefail
The bash option that makes a pipeline fail if any stage fails, instead of reporting only the last stage's status.
In more detail
Without it, grep missing file | cat succeeds because cat succeeded, so set -e never notices. With it, the pipeline returns the status of the rightmost failing stage.
Related terms
- set -euo pipefail — The line many bash scripts put just under the shebang to turn on set -e, set -u and pipefail together.
- set -e — The shell option that makes a script exit as soon as a command fails, instead of carrying on.
- pipe — The | operator, which connects one command's standard output to the next command's standard input so they run together.
- exit code — A number a process returns when it finishes: 0 means success, anything else means something went wrong.
Taught in
- set -e, set -u And pipefail: Promises And Traps — Bash Scripting & Command Line Automation
- trap, Cleanup And Temporary Files — Bash Scripting & Command Line Automation
- Style That Prevents Bugs — Bash Scripting & Command Line Automation
- Scheduling, Monitoring And A Script That Reports — Bash Scripting & Command Line Automation
- What Is a Pipeline? — Continuous Integration & Continuous Delivery Pipelines
- Passing Data Between Jobs: Artifacts — Continuous Integration & Continuous Delivery Pipelines
- The Cleanup That Emptied The Wrong Directory: Shell Scripts Under Exam Conditions — CompTIA Linux+ (XK0-006) Exam Prep
References
- Bash Reference Manual: The Set Builtin (pipefail)
- Bash Reference Manual: Pipelines
- bash(1) manual page: the set builtin