On 9/28/24 15:53, Tim Woodall wrote:
Is there a way in bash to guarantee that a trap gets called for cleanup
in a script?
I have a script that works perfectly normally and cleans up after
itself, even if it goes wrong.
However on trying to debug something else, I wanted to run it like this:
./script |& tee log
and now it doesn't clean up if I <ctrl c> it.
Is there a way in bash to guarantee (modulo uncatchable signals) that a
cleanup routine gets called?
You need to trap the CTRL C and execute that same clean up routine.
As I don't use Bash you might want to look online for some insperation.
--
John Doe