Defensive bash.
`set -euo pipefail` at the top of every script means:
-e exit on the first error
-u error on use of unset variable
-o pipefail a pipeline fails if any stage fails
Without these, a typo in a variable name silently produces an empty
string, and your script happily `rm -rf "$EMPTY/"` your home dir.
Which line is the IDIOMATIC defensive bash header?
A) #!/bin/bash; set debug
B) #!/bin/bash; set -euo pipefail
C) #!/bin/bash; trap 'echo bye'
D) #!/bin/bash; set +e
Sign in to save your code and track progress across devices.