Sams Teach Yourself Shell Programming in 24 Hours (Web server address)
Sams Teach Yourself Shell Programming in 24 Hours Contents Index Hour 20: Debugging Previous Chapter Next Chapter Sections in this Chapter: Enabling Debugging Summary Syntax Checking Questions Shell Tracing Previous Section Next Section Hour 20 Debugging In this book you have looked at scripts that are quite short. Thus, the issue of debugging them has boiled down to looking at their output and making sure it is correct. For larger shell scripts, especially the kind that change system configurations, trying to deduce the source of a problem from a script’s output is insufficient. Often, by the time you get the output, it is too late–the script will have made incorrect modifications or changes. Another common scenario is adding features to a large script that someone else developed. In such cases you need to make sure your changes don’t affect the rest of the script. Fortunately, the shell provides several built-in commands for enabling different modes of debugging support. In this chapter you learn how to enable debugging, and then you will look at how to use the following debugging modes: l Syntax checking l Shell tracing Enabling Debugging By now, you are quite familiar with the basic syntax for executing a shell script: $ script arg1 arg2 … argN Here script is the name of the script, and arg1 through argN are the arguments to the script. A frequently used alternative method to execute a shell script is $ /bin/sh script arg1 arg2 … argN Here you explicitly specify the shell, in this case /bin/sh, that you used to execute the script. The advantage of this method is that you can enable a debugging mode by supplying arguments to the shell. Using this method of script invocation, the basic syntax for enabling a debugging mode is $ /bin/sh option script arg1 arg2 … argN Here option is one of the debugging options covered in Table 20.1.
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.