1. If-then-elseif in C-shell
Beware of the "else if" construct in a C shell. Apparently, csh tries
a variable substitution before it recognizes that this is an else line:
#
if ($argv[1] == "boy") then
echo puer
else if ($argv[2] == "girl") then
echo puella
else
echo "???"
endif
So if you give it a command line with only 1 argument, it will bomb
on $argv[2] and say "Subscript out of range." For example, if the
above is in a file called "doit", then the following invocations produce
the following results:
doit boy xxx ==> puer
doit boy girl ==> puer
doit xxx xxx ==> ???
doit xxx girl ==> puella
doit boy ==> puer
Subscript out of range.
if you do
csh -vx doit boy
you will see that it actually attempts to interpret the else if
statement, and fails when it sees that there is only 1 argument.