I have a function in bash which captures the keyboard interrupt. The function looks like this:
user_interrupt(){
echo -e "\n\nKeyboard Interrupt detected."
sleep 2
echo -e "\n Cleaning up..."
rm -rf /usr/local/src/mysources
}
Now, in the same script, I have another function called install()
that installs a few packages from source one after the other using the standard ./configure
, make
, make install
process. The idea is to capture the user interrupt from while running the 3 installations one after the other. Question is, where do I place the following statements:
trap user_interrupt SIGINT
trap user_interrupt SIGTSTP
So should I place it as the first statement inside the install()
function? Or do I need an if-else
condition?
install()
function? – Whoop