Csh: first character of an arg is '-'

Jak Kirman jak at cs.brown.edu
Sun Oct 7 10:25:05 AEST 1990


Context: SunOS 4.1, /bin/csh

I want to be able to test whether the first character of an argument to
a csh-script is '-'.  The man page makes it sound like ~= should work
for this, but I could make no sense of that portion of the man page, and
was not able to find any case where the result of ~= was non-0 except
the trivial case where the right-hand side contained no wildcards and
was the same as the left...

I do *not* want to have to exec a program; I want this to be fast.

Please do not tell me to use sh -- I know it is better for scripts, but
the syntax is rather arcane, and I don't have the time to learn it right
now, although eventually I will probably have to.  If you are quite
certain this is not possible in csh, but it is in sh, I would appreciate
a quick example of sh usage.

As an aside, is there any way to find the first character of a word in
csh or sh?

Thanks.
                                Jak                            jak at cs.brown.edu
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
He had been kicked in the head by a mule when young, and believed
everything he read in the Sunday papers.
                                                              -- George Ade



More information about the Comp.unix.shell mailing list