Skip to content

Instantly share code, notes, and snippets.

@lawrencegripper

lawrencegripper/trap.sh

Last active May 11, 2020
Embed
What would you like to do?
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
You can’t perform that action at this time.