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: Re: Match operator puzzlement
Date: Sun, 2 Feb 1992 14:20:38 -0600	[thread overview]
Message-ID: <9202021520.aa00569@ceres.srg.af.mil> (raw)

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

John Mackin writes:

> The reason a straightforward attempt doesn't work isn't really anything
> to do with rescanning at all, since there IS no rescanning

I thought about adding "or lack thereof", honest I did!  But since it
seemed to imply that not rescanning was wrong it got left out.  The
real difficulty, which I saw quite clearly, is that ~ doesn't accept a
list of patterns (primarily so you can match the empty list) so the
eval is needed to flatten the command out and rescan it (flattening the
list doesn't work because it becomes a single item) but at this point
we get undesired rescanning (in a filename context?) which is not
easily quoted away. 

There also seems to be a minor ambiguity between string matching
contexts and filename expansion contexts. In most contexts $ gives the
contents of variable (or something related) and patterns (using * ? [])
give a list of filenames.  In matching contexts $ works the same but
patterns are compared against strings.  Where the two collide it gets a
bit messy.  Given:

	patterns=('*.o' '*.a')		# or patterns='*.o *.a'
	eval ~ '$i' $patterns

It's not clear to me which context *.o will be evaluated in.  Will it
filename expand to a whole list of patterns which are then matched? 
This matters for obvious reasons.  Maybe Byron can clarify this?

For the curious the application is to scan a development directory tree
automatically generating a makefile/target for configuration management
purposes.  One of the requirements was to be able to exclude files
matching a certain template or set of templates (given on the command
line) from the target, typically things like *.o *.a and other
generated or binary files.  While testing it I actually did encounter a
filename with a $ in it (a backup or temporary file for some app) 8-P
and while I don't like names like that, my program can't just choke on
them!

My less than satisfactory solution was to carefully document that the
patterns had to be quoted, just so, when they are given on the command
line.  Byron's sed script seems like it will solve most of the problem
and John's newline hack should cover any remaining glitches.

Tom


             reply	other threads:[~1992-02-03 14:49 UTC|newest]

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

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=9202021520.aa00569@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).