1
“Exit traps” can make your Bash scripts more robust and reliable (2013)
There is a simple, useful idiom to make your bash scripts more robust - ensuring they always perform necessary cleanup operations, even when something unexpected goes wrong. The secret sauce is a pseudo-signal provided by bash, called EXIT, that you can trap ; commands or functions trapped on it will execute when the…