Created
February 14, 2019 20:59
-
-
Save fel-cesar/ac71c58dfcd04457b0e6ab36b1c362f6 to your computer and use it in GitHub Desktop.
Sample script to demonstrate how to capture a 'trap' command in terminal
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 | |
# trap ctrl-c and call ctrl_c() | |
trap ctrl_c INT | |
function ctrl_c() { | |
echo "** Trapped CTRL-C" | |
exit 1 | |
} | |
for i in `seq 1 5`; do | |
sleep 1 | |
echo -n "." | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment