Csh: first character of an arg is '-': Solution

Jak Kirman jak at cs.brown.edu
Mon Oct 8 01:54:58 AEST 1990


The test to see whether the first character of $i was '-' should have
been 

if ( x$i =~ x-* ) then          not
if ( $i =~ -* ) then

Several of the original replies used this, but I mistakenly thought it
was unnecessary, since it worked without it too.  But as was pointed out
to me, if $i has a special meaning to the shell, like -e or -x etc, it
will complain about the lack of a filename to do the existence or
executability test on.  Adding something like an 'x' or a " " before
both tests will solve this problem.

Sorry about the incorrect simplification of your answers :-)

                                Jak                            jak at cs.brown.edu
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For the female of the species is more deadly than the male.
                                     -- Kipling, "The Female of the Species"



More information about the Comp.unix.shell mailing list