Chapter 23. Debugging scripts

One of the most annoying tasks of shell scripting is debugging problems. There are aids to help you but, to prevent most errors before they happen, follow this rule:

Break your proposed script down into tasks or procedures, then code and test each procedure before continuing with the next step.

In this chapter we will cover:

  • common errors; and

  • introducing the set command.

There really is nothing more irritating than trying to discover an elusive error in your script. However, as you get more experienced in scripting you’ll know what to look for.

The most common problems are missing quotes or not having an fi on the end of an if statement.

One important thing to remember is that when the shell reports an error from ...

Get Linux and Unix Shell Programming 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.