Safe Bash script template
Bash
#!/usr/bin/env bash
set -Eeuo pipefail
cleanup() {
# Remove temporary files or stop background jobs here.
:
}
trap cleanup EXIT
main() {
local input="${1:?usage: $0 <input-file>}"
[[ -f "$input" ]] || { echo "not a file: $input" >&2; exit 1; }
echo "processing $input"
}
main "$@"