Linuxlab

Strict mode: set -euo pipefail

Updated July 3, 2026

By default bash keeps going after an error. In a script that is dangerous: one failed command and the rest runs on a broken state. set -euo pipefail makes the behaviour strict.

#!/usr/bin/env bash
set -euo pipefail
# -e  exit on the first error
# -u  error on an unset variable
# -o pipefail  error if any command in a pipeline fails

Put this line right after the shebang. A full walk through each option is in Part III of the textbook.

Used in

You need this in the lesson Bash: writing scripts.