Created
March 8, 2015 00:41
-
-
Save namioka/5f9f4200e8681adc3d82 to your computer and use it in GitHub Desktop.
bash trap
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 | |
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