Orange Sunshine |
09-26-2011 11:49 AM |
Bash script - if error then [do something]
Hello,
So I have a bash script with the set -e flag and for the most part it does exactly what I need it to. If there is an error executing something within the script it will break out of the script as to not cascade error on top of error.
My issue is, I have some cleanup that is done at the end of the script and this cleanup needs to happen before running the script again (the script will error out if cleanup isn't done). If there is an error while executing I have to go and perform that cleanup manually before I can try to run it again. Is there any way to basically say - if there is an error then perform this cleanup first then break out of the script?
|