Csh: first character of an arg is '-': Solution
Jak Kirman
jak at cs.brown.edu
Sun Oct 7 14:18:15 AEST 1990
Before I get flooded with more replies, let me post the answer that
barnett at crdgw1.ge.com, raymond at math.berkeley.edu and
christos at theory.tn.cornell.edu all basically gave me:
foreach i ($*)
if ( $i =~ -* ) then
# is an arg
else
# is not
endif
end
Apart from the typo ~= instead of =~ , my problem was that I was quoting
the right hand side, thinking that I did not want filename expansion,
though as Raymond pointed out, I *do* want filename expansion, but
expansion in the context of the left hand side, not of the current
directory. It seems like strange magic to me, but it works...
So thank-you for the replies. By the way, no-one yet has answered my
second question: can you extract a character from a word? (Again, no
forking allowed).
Jak jak at cs.brown.edu
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Contrepet du jour: Quand les Nippons arrivent, la Chine se souleve.
More information about the Comp.unix.shell
mailing list