Debugging Hooks
One of the easiest and most effective ways to debug a script is to judiciously place print statements in it to display the current contents of troublesome variables. This technique is not smooth or sexy, but it is very effective.
If your script development is ongoing, you might want to insert some debugging hooks in the script that indicate whether to display the variable contents. If you choose, you can remove the extra print statements after the script is debugged. However, I suggest leaving them in the script because the overhead of leaving them in will probably be minimal. This option is more directed than the ksh -xv technique and produces less busy output.
As you start the script, you can give it an extra command line option, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access