#!/usr/bin/env bashenv runs a program in a modified environment, the command in this case being
the first copy of bash found within ${PATH}.
SCRIPT_DIR="$( cd -P -- "$( dirname -- "$(readlink -f "${BASH_SOURCE[0]}")" )" >/dev/null 2>&1 && pwd )"#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'-e: immediately exit if a command has a non-zero exit status-u: references to an undefined variable cause the script to exit-o pipefail: returns non-zero exit statuses from any command in a set of
piped commands instead of the exit code of the final commandIFS: each character is a delimiter used by bash for separating arguments,
so we avoid arguments with spaces, for example, being incorrectly parsed in
bash loopsAt the start of your file set up a trap with a cleanup function that should be run.
#!/usr/bin/env bash
function finish {
# cleanup
}
trap finish EXIT