72 / 80 · 12 Programming for QA · Bash Scripting for QA← prev⊞ allnext →☰ Read as one page
9.2The Essential Script Template
Every bash script should start with this:
#!/bin/bash
set -euo pipefail
| Flag | Meaning | Why It Matters |
|---|---|---|
set -e |
Exit on any error | Prevents scripts from silently continuing after a failure |
set -u |
Error on undefined variables | Catches typos in variable names |
set -o pipefail |
Pipe fails if any command in the pipe fails | `cmd1 |
Without these flags, a script can fail silently — the database reset fails, but the tests still run against stale data.