bash-strict-mode.sh
#!/usr/bin/env bash
set -Eeuo pipefail
tmp="$(mktemp -d)"
cleanup() { rm -rf "$tmp"; }
trap cleanup EXIT
trap 'echo "error on line $LINENO" >&2' ERR
echo "working in $tmp"
Stop on errors, unset variables and failed pipes, and clean up on exit.