rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* Style question, some examples
@ 1991-10-23 17:05 Rich Salz
  0 siblings, 0 replies; only message in thread
From: Rich Salz @ 1991-10-23 17:05 UTC (permalink / raw)
  To: rc

I try to make all variables in my functions local; the sample below shows
how I've been declaring them.  Any other suggestions?

I've also taken to using && and || instead of "if" -- I try to only write
an "if" when I'm going to need an "else"  Comments?

Anyhow, here's what prompted me to write -- the following is a different
version of the "src" function.  The major difference is that if you
have foo.y and foo.c, it will list foo.y but NOT foo.c as a source file.
(It does get confused about foo.h in that case, but c'est la vie).
The reason I'm sending this in is because I was pleased to figure
out the ~ pattern...  (Yes, old news to non-csh users, or set nonomatch :-)

    fn sources { *=(*.[cylh]) i=() {
	for (i) {
	    switch ($i) {
	    case *.[ylh]
		echo $i
	    case *.c
		~ `{basename $i .c }^.[ly] '*.[ly]' || echo $i
	    }
	}    
    } }

/r$


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1991-10-23 17:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-10-23 17:05 Style question, some examples Rich Salz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).