Skip to content

Instantly share code, notes, and snippets.

@namioka
Created March 8, 2015 00:41
Show Gist options
  • Save namioka/5f9f4200e8681adc3d82 to your computer and use it in GitHub Desktop.
Save namioka/5f9f4200e8681adc3d82 to your computer and use it in GitHub Desktop.
bash trap
#!/bin/bash
function trap_exit() {
test -f $$ && rm $$
}
set -e
trap "trap_exit" EXIT
touch $$
ls not_exist
echo OK
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment