Skip to content

Instantly share code, notes, and snippets.

@devguydavid
Last active December 11, 2015 17:08
Show Gist options
  • Save devguydavid/4631872 to your computer and use it in GitHub Desktop.
Save devguydavid/4631872 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
function cleanup {
echo "Removing /tmp/foo"
rm -r /tmp/foo
}
trap cleanup EXIT
mkdir /tmp/foo
asdffdsa #Fails
@devguydavid
Copy link
Author

Output:

dbrown@luxury:~ $ sh trap_example.sh
t: line 9: asdffdsa: command not found
Removing /tmp/foo
dbrown@luxury:~ $

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment