DevOps · Flashcard

Why do robust scripts commonly begin with set -euo pipefail?

  • ATo fail fast on errors, on unset variables, and on failures anywhere in a pipeline
  • BTo silence all command output, disable history, and speed up command execution
  • CTo enable verbose tracing, keep running past errors, and log output to syslog
  • DTo run the whole script with elevated privileges and a tightly restricted PATH

Why this is the answer

It combines -e (exit on error), -u (error on unset vars), and -o pipefail (a failing pipeline stage fails the pipeline) — a strict, fail-fast baseline. Option two invents unrelated quiet/performance flags. Option three is self-contradictory (these flags stop, not continue) and there is no syslog option. Option four describes privilege/PATH changes these flags never make.

Official docs
Study in Gnoseed →