Using Shell Script Debugging Tools and Techniques
There are a few different debugging tools that we can use, which include shellcheck
, checkbashisms
, and shall
. We’ve already looked at them in Chapter 19—Shell Script Portability, so we won’t look at them again here. Instead, I’ll present some tools and techniques that we haven’t covered yet.
Using echo Statements
Sometimes, if you have a problem with a shell script that you can’t figure out, placing echo
statements in strategic locations can help you find the problem.
You may see in other references that some people think of echo
statements as the poor man’s debugging tool. That’s because echo
is always available, and can be used if you can’t use anything else.
Back in Chapter 16, Creating User Interfaces with yad, dialog, and xdialog, I showed you the xdialog-hello2.sh
script, which can automatically detect two things.
- It can detect...