I am trying to do validation for every function I call in a script and erroring out the whole script if one function fails.
Looking for the best way to do this. I feel I knew a good way to do it at one time, but can't figure it out again.
I can brute force it, but it's nasty. This is how I can get it to work correctly
copy_files $1
if [ "$?" -ne "0" ]; then
error "Copying files"
return -1
fi
This gets pretty ugly since I have a script that goes:
command1 command2 command3
Having to wrap all these commands with returns is not very ideal. :( Please help!