🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.shell
Article #1407

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

#1407
From: Jak Kirman
Date: Sun, 07 Oct 1990 04:18
24 lines
1467 bytes
Before I get flooded with more replies, let me post the answer that
barnett@crdgw1.ge.com, raymond@math.berkeley.edu and
christos@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@cs.brown.edu
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Contrepet du jour:  Quand les Nippons arrivent, la Chine se souleve.
Technical Details
Message-ID: <JAK.90Oct7001815@bimini.cs.brown.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!brunix!doorknob!jak

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!brunix!doorknob!jak
From: jak@cs.brown.edu (Jak Kirman)
Newsgroups: comp.unix.shell
Subject: Csh: first character of an arg is '-': Solution
Message-ID: <JAK.90Oct7001815@bimini.cs.brown.edu>
Date: 7 Oct 90 04:18:15 GMT
Sender: news@brunix.UUCP
Reply-To: jak@cs.brown.edu
Distribution: comp
Organization: Department of Computer Science, Brown University
Lines: 24