rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: culliton@srg.af.mil (Tom Culliton x2278)
To: rc@archone.tamu.edu
Subject: Match operator puzzlement
Date: Fri, 31 Jan 1992 15:01:15 -0600	[thread overview]
Message-ID: <9201311601.aa02527@ceres.srg.af.mil> (raw)

Reply-To: srg!culliton@uunet.uu.net

OK maybe it's just 'cuz it's Friday but my poor brain refuses to come
up with a good answer to this one.  While writing some fairly large and
complex rc scripts I had a requirement to match something against a
list of patterns specified at the command line and figured it'd be easy
give rc's ~ match operator.

The first attempt was something like this:

	patterns=`{echo $1}	# go from '*.o *.a' to (*.o *.a)

	# lots of stuffto generate a list on file names....

	for (i in $list) {
		if (~ $i $patterns) {
			dealwith $i
		} else {
			handle $i
		}
	}

Which didn't work as planned for semi-obvious reasons involving
re-scanning.  This didn't distress me too much because I mostly
understood why after a bit of thought.  The next most obvious thing to
try was somthing like this

	patterns=$1	# we don't care if it's a list for this

	# lots of stuff to generate a list on file names....

	for (i in $list) {
		if (eval ~ $i $patterns) {	# etc...

OOPS! I encountered a file name with a $ in it so make that

		if (eval ~ '$i' $patterns) { 	# etc...

But what about patterns with $ and so forth in them?  If we make
$patterns a list again and say '$patterns' to protect against that, we
get literal matching.  I haven't been able to find a way out of the
swamp here any words of wisdom would be appreciated.

Thanks for listening.

Tom


             reply	other threads:[~1992-01-31 21:12 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-01-31 21:01 Tom Culliton x2278 [this message]
1992-02-01 16:02 ` John Mackin
1992-02-01 17:49 Byron Rakitzis
1992-02-01 18:02 ` John Mackin
1992-02-01 18:43 malte
1992-02-01 19:46 malte
1992-02-02 20:20 Tom Culliton x2278
1992-02-03 17:09 Byron Rakitzis

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=9201311601.aa02527@ceres.srg.af.mil \
    --to=culliton@srg.af.mil \
    --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).