I have created a bash trap that traps CTRL + C and calls a function ctrl_c. This function just displays a message and starts a counter then returns to the main function.
The trap works fine the first time of running but if tried a second time it displays C^ although it does disable CTRL + C it doesn't call the function again.
Is there a way to reset the trap to run like the first instance.
Thanks in advance.
Code;
function ctrl_c() {
clear
echo "** Trapped CTRL-C"
echo -n "Press [ Enter ] to continue."
read
for i in $(seq 1 5);
do
let timer="5 - $i + 1"
clear
echo "Returning to main menu in.. $timer"
sleep 1
done
main
}
trap ctrl_c INT