Ravi Sir's Cards › AWS
Safe script template
This revision card explains Safe script template. It starts from the need that strict mode. It describes usage and exit 2. The how-to section notes temp and cleanup. An example on the card is quote every var.
Read card text
What this card says
Why do we need it?
Strict mode.
set -euo pipefail
What is it?
Usage and exit 2.
usage(){ ...; exit 2; }
How to do it
Temp and cleanup.
trap 'rm -rf "$t"' EXIT
Example
Quote every var.
"$file"