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.

An alternative method to execute a shell script is

$ /bin/sh opt
						script
						arg1
						arg2 ... argN
					

This invokes the shell, in this case /bin/sh, with the debugging option specified by opt and instructs the shell to execute script. Table 20.1 lists the various debugging options.

A second way to enable debugging is to change the first line of script. Usually, the first line of a script is

#!/bin/sh

UNIX uses this line to determine the shell you can use to execute a script. This indicates that the shell /bin/sh should be used to ...

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.