The first two statements of your BASH script should be… shell bash
#!/usr/bin/env bash set -euo pipefail
Safer bash scripts with ’set -euxo pipefail’ · vaneyckt.io bash
Almost the same as above 🙃.
Bash Error Handling with Trap - citizen428.net
Traps in Bash are used for executing a command or series of commands upon catching a signal.