Earlier a number of ways to run a script were presented. There is yet another, which makes debugging easier. If you invoke the script with the csh command you can specify none or one or more options. The command takes the form
% csh [options] script
where script is the file. There is a choice of two debugging
options.
% csh -x myscript
% csh -v myscript
The x option echoes the command lines after variable substitution,
and the v option echoes the command lines before variable
substitution. The v is normally used to identify the line at
which the script is failing, and the x option helps to locate
errors in variable substitution. As these options can produce lots of
output flashing past your eyes, it is often sensible to redirect the
output to a file to be examined at a comfortable pace.
If you prefer, you can run the script in the normal way by putting the option into the first comment line.
#!/bin/csh -x
C-shell Cookbook