Last active
June 27, 2020 10:04
-
-
Save tamalsaha/dec0c373b7142092ba2d1435c1e322f8 to your computer and use it in GitHub Desktop.
Bash script template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eou pipefail | |
SCRIPT_ROOT=$(realpath $(dirname "${BASH_SOURCE[0]}")/../..) # adjust as needed to go to root directory | |
SCRIPT_NAME=$(basename "${BASH_SOURCE[0]}") | |
pushd $SCRIPT_ROOT | |
# http://redsymbol.net/articles/bash-exit-traps/ | |
function cleanup() { | |
popd | |
} | |
trap cleanup EXIT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment