How to Handle Signals and Errors in Bash Scripts