set - set or unset shell options and positional parameters
set [-euxo OPTION] [--] [ARG]...
Options you will use
-e, -o errexit- Exit on an untested non-zero status.
-u, -o nounset- Error on an unset variable.
-x, -o xtrace- Print each command before running it.
-o pipefail- A pipeline fails if ANY element fails, not just the last.
+OPTION- Turn the option back off.
-C- noclobber:
>refuses to overwrite an existing file (use>|to force). +C turns it off. -E- errtrace: the ERR trap also fires inside functions and subshells.
Gotchas
set -euo pipefailis the standard script header - but know its gaps: conditions, && / ||, andlocal x=$(cmd).
Taught in
Try set in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.