[Chapter 8] 8.17 verbose and echo Variables Show Quoting
Author: Jerry Peek, Tim O'Reilly & Mike Loukides
Date: 1998-08-04T21:34:34Z

#

| Chapter 8 How the Shell Interprets What You Type |

## 8.17 verbose and echo Variables Show Quoting

The C shell has two variables (6.9) that, when set, will help you follow the convoluted trail of variable and metacharacter expansion. This will echo every command line before shell variables have been evaluated:

    set
    % set verbose

This command will display each line after the variables and metacharacters have been substituted:

>     % set echo

If you wish to turn the variables off, use unset (6.8) instead of set.

The Bourne shell syntax is different. To turn on the verbose flag, use:

>     $ set -v

The command `set` `-x` turns on the echo flag. You can also type them together: `set` `-xv`.

If your version of UNIX understands (44.4) scripts that start with `#!`, here's a convenient way to turn these variables on from the first line of a script:

>     #!/bin/sh -xv

It is not necessary to modify the program. You can enable variable tracing in Bourne shell scripts by typing the shell name and options on the command line:

>     $ sh -v script
>     $ sh -x script

Not all Bourne shells let you turn these variables off. If yours does, you can do it by using a plus sign instead of a minus sign:

>     set +xv

- BB

8.16 Quoting Handles Special Characters in Filenames |  | 8.18 Here Documents