Ravi Sir's Cards › AWS
Script template
This revision card explains Script template. It starts from the need that strict mode. It describes log and die. The how-to section notes lock. An example on the card is temp and cleanup.
Read card text
What this card says
Why do we need it?
Strict mode.
set -Eeuo pipefail
What is it?
log and die.
die(){ log ERROR "$*"; exit 1; }
How to do it
Lock.
exec 9>/tmp/x.lock; flock -n 9
Example
Temp and cleanup.
trap 'rm -rf "$tmp"' EXIT