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, ...

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.