rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: Rich Salz <rsalz@bbn.com>
To: rc@archone.tamu.edu
Subject: Style question, some examples
Date: Wed, 23 Oct 1991 12:05:05 -0500	[thread overview]
Message-ID: <9110231705.AA29730@litchi.bbn.com> (raw)

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$


                 reply	other threads:[~1991-10-23 17:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9110231705.AA29730@litchi.bbn.com \
    --to=rsalz@bbn.com \
    --cc=rc@archone.tamu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).