Created
August 23, 2017 11:51
-
-
Save kuntalchandra/b9396b627920feacd9a28488c7fabbdc to your computer and use it in GitHub Desktop.
bash: Trap error and exit
This file contains hidden or 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 | |
trap "exit 1" TERM | |
TOP_PID=$$ | |
function alert() | |
{ | |
echo "Do something" | |
kill -s TERM $TOP_PID | |
} | |
echo "Function call to stop execution" | |
alert | |
echo "This message won't be printed ever" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment