Skip to content

Instantly share code, notes, and snippets.

@lawrencegripper
Last active September 21, 2021 19:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lawrencegripper/9e778601b2a21d7891e46cf0e1765f46 to your computer and use it in GitHub Desktop.
Save lawrencegripper/9e778601b2a21d7891e46cf0e1765f46 to your computer and use it in GitHub Desktop.
Cleanup in Bash script
#!/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