4 ms·
plus the delightful mechanism of set -euo pipefail # stop execution if anything fails cleanup () { rm $tmp_file popd # anything
by 1-more 2y ago
plus the delightful mechanism of
set -euo pipefail # stop execution if anything fails
cleanup () {
rm $tmp_file
popd
# anything else you want to think of here to get back to the state of the
# world before you ran the script
}
trap cleanup EXIT # no matter how the program exits, run that cleanup function.
A really good rundown of the different options for set https://www.howtogeek.com/782514/how-to-use-set-and-pipefail-in-bash-scripts-on-linux/ https://www.howtogeek.com/782514/how-to-use-set-and-pipefail...