If set -e
is set, non-zero exit code during script run will terminate the execution.
To prevent immidient termination and add some logic to cleanup stuff, you may need to use trap
command:
#!/usr/bin/env bash
set -e
function cleanup {
echo "Removing $TMP_STUFF_DIR"
rm -f "$TMP_STUFF_DIR"
}
trap cleanup EXIT
...