How can I trigger a function when a command in bash returns an exit code of 1? I know set -e at the top will just make my code terminate, but I want to call this function first. If the code runs ok I want it to exit normally without the function being called. I don't want to do a $? check after every line. I'm sure there's an easy way to do this but I'm new to bash scripting so I don't know it offhand.
Add a comment
|