Strict Mode: set -euo pipefail

set -euo pipefail makes a script stop at the first sign of trouble: -e stops at a command that fails, -u at a variable that was never set, and -o pipefail at a pipeline with a failing part, with a few surprises to know about: a grep that finds nothing, ((count++)) and a missing $1.

Updated

Cheat sheet for the lesson Strict Mode: set -euo pipefail: set -euo pipefail makes a script stop at the first sign of trouble: -e stops at a command that fails, -u at a variable that was never set, and -o pipefail at a pipeline with a failing part, with a few surprises to know about: a grep that…
Category
Bash
Level
Freelancer
Tags
exit-code, linux, pipeline, shell-variable, strict-mode, unix