“Exit Traps” Can Make Your Bash Scripts Way More Robust and Reliable

by kevinslinon 6/27/23, 1:19 PMwith 7 comments
by chasilon 6/27/23, 1:39 PM

This appears to be a duplicate of a recent post.

https://news.ycombinator.com/item?id=36400465

by noahjkon 6/27/23, 1:44 PM

Very similar to Python's "finally" keyword [0] used in a try block, the "Exit Traps" are meant to allow for clean-up action(s) if a script fails.

[0]: https://docs.python.org/3/tutorial/errors.html#defining-clea...

by Rucadion 6/27/23, 1:52 PM

It is better to avoid bash scripts altogether :)