Set shell options and positional parameters; control script safety.
medium risk
set configures shell options that dramatically affect script behavior. `set -e` makes scripts exit on any error. `set -u` treats unset variables as errors. `set -o pipefail` catches failures in pipelines. Together, they make scripts fail-fast and safe.
set -euo pipefailEnable all safety options (recommended at top of all scripts) · explain & risk-check →set -xEnable debug mode: print each command before executing · explain & risk-check →set +xDisable debug mode · explain & risk-check →set -e; false; echo 'never reached'Demonstrate exit-on-error · explain & risk-check →Start every bash script with `#!/bin/bash\nset -euo pipefail` — `e` exits on error, `u` catches unset variables, `pipefail` catches pipeline failures. This prevents 90% of silent script bugs.
Reference text is hand-written and may be incomplete — check man set for your version. Test destructive commands on a non-production system first.