Hour 20. Debugging

Most of the scripts you have looked at have been quite short, thus the issue of debugging has boiled down to examining the output to ensure it is correct. For larger shell scripts, especially scripts used to change system configurations, trying to deduce the source of a problem based on just output is insufficient. By the time you get the output it might be too late—the script could have made incorrect and possibly destructive modifications.

Fortunately, the shell provides several built-in commands for enabling different modes of debugging support. The built-in debugging support can be very helpful when you need to add features to a large script that someone else developed; it can help you ensure that your changes don't affect ...

Get Sams Teach Yourself Shell Programming in 24 Hours, Second Edition 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.