I've been looking a while to see if there is way to create a smart error handling in a bash script. Nothing has popped up so I figured that you guys gotta know if it's even possible.
Let's say we have a script that has a section of copying files and instead of testing if
every copy is OK I want to know if there is a way to test this "section" of copying.
... or if you have a section in the script that deletes files and directories and here too,
instead of testing everyone, check to see if there are errors in that.
I've seen things that you can put everything withing curly brackets '{}' something like this:
Code:
{
cp -pr "$PDdir"/PD-dsa.pem $bkupdir$PDdir &&
cp -pr /data/install/install.cfg $bkupdir$PDdir &&
} || {
echo "BKUP ERROR: Error in copying dirs/files to $bkupdir$PDdir" key
}
I've tested this but it won't work or if I'm doing something wrong with it, donno.
So what I want is an easy way to test sections for errors/warnings instead of test each
row that just makes the script unreadable.