Last active
September 21, 2021 19:25
-
-
Save lawrencegripper/9e778601b2a21d7891e46cf0e1765f46 to your computer and use it in GitHub Desktop.
Cleanup in Bash script
This file contains 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 -e | |
function cleanup() | |
{ | |
echo -e "----> Trap caught! Do cleanup here" | |
} | |
trap cleanup EXIT | |
# imagine some stuff happens here | |
# and it exists | |
exit 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment