Chapter 11. Debugging Shell Scripts
According to legend, the first computer bug was a real insect, a moth that caused problems for the inner workings of an early computer. Since that time, problems in computer software have been termed bugs. Debugging is the glorified act of removing errors from your scripts.
Let's face it, scripts aren't always perfect. Even so, almost everything surrounding bugs remains controversial. Whether a particular behavior in a program or script is a bug or a feature can inspire great debate. Many companies consider the term bug itself to be pejorative, so they mandate more innocent-sounding terms. For example, Microsoft uses issue instead of bug. Apparently, using the term bug or defect could imply that their software isn't perfect.
Calling a behavior a bug can hurt people's feelings. For your own scripting efforts, however, consider debugging to simply be the act of making your scripts work the way you'd like and leave it at that.
Scripts can create a lot of havoc on your system. For example, your script may remove files necessary for the system to properly function. Or, worse yet, your scripts might accidentally copy a file on top of a crucial system file. The act of changing file permissions may inflict your system with a security hole. For example, a malicious script was discovered as one of the first attacks on Mac OS X systems. Therefore, numerous issues demand your attention.
In most cases, though, you simply need to do the following:
Determine what ...
Get Beginning Shell Scripting 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.