I have a shell script which I am using to call many python scripts. I've added a trap in my shell script to catch ctrl+c and exit. But if a python script is running and I hit ctrl+c, it also shows the block of the python script that was being executed! I do not want that. I know the better way would be to add KeyboardInterrupt in my python scripts, but that will take a lot of effort. I want a solution such that when I hit ctrl+c, te control the script execution ends silently.
for eg: a.sh:
control_c() {
echo
echo 'Keyboard Interrupt'
exit
}
trap control_c INT
python b.py
b.py:
from time import sleep
sleep(50)
when I run a.sh and I hit ctrl+c, I do not want to see the python block like this:
^CTraceback (most recent call last):
File "b.py", line 3, in <module>
sleep(50)
KeyboardInterrupt
Keyboard Interrupt
I want it to exit with a simple 'Keyboard Interrupt' message.