...
There are mechanisms in bash that provide some of this functionality (see especially set -e and set -x decsribed described in https://www.turnkeylinux.org/blog/shell-error-handling and http://linuxcommand.org/lc3_wss0150.php, and trap-ing signals in http://linuxcommand.org/lc3_wss0150.php).
...
- To stop execution immediately when an error is detected
- Have the last line of the log file describe the fatal error (easy to tail)
- Make it easy to frequently check for errors of different sorts in our code
- Report the check being done (even when successful) in order to leave "bread crumbs" in the log file for troubleshooting.
- Report all diagnostics to standard error so it will not interfere with a function's standard output that is meant to be captured by the caller
- So if a function reports error checks to standard error, and also reports information on standard output, only the standard output will be captured by backtick or parentheses evaluation.
The step_04.sh Script
Here's a step_04.sh script that builds on our step_03.sh work, located in ~/workshop/step_04.sh.
...