zsh-users
 help / color / mirror / code / Atom feed
* Re: how can I skip globbing through SCCS subdirs?
       [not found] <199511100311.TAA07019@kontiki.Eng.Sun.COM>
@ 1995-11-10  8:53 ` P.Stephenson
  1995-11-10 19:09   ` John S Cooper
  0 siblings, 1 reply; 2+ messages in thread
From: P.Stephenson @ 1995-11-10  8:53 UTC (permalink / raw)
  To: John S Cooper; +Cc: Zsh users list

John.Cooper@eng.sun.com wrote:
> I'm using extendedglob.  How can I match all .c files in all
> subdirectories, _except_ any SCCS subdirectories?
> 
> ls **~SCCS/*.c

The bad news is that ** handling bypasses most of the pattern code,
i.e. you can't actually exclude things while the ** list is being
expanded.  The good news is that in the ~ part of the pattern, /'s are
not special.  This means you can exclude SCCS directories like this:

ls **/*.c~(*/)#SCCS/*

The (*/)# is a trick so that top level SCCS directories are ignored as
well as any /SCCS/ bits in the middle somewhere.

By the way, as this shows, ~ has lower precedence than /.  That's
because it was originally intended that you only use ~ the way I've
just done, i.e. with the whole pattern.  However, you can now group it
using parentheses if you avoid using ** inside the parentheses (so it
doesn't solve your problem here).

> Ps. Is there a newsgroup for this alias?

No, sorry.

-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: how can I skip globbing through SCCS subdirs?
  1995-11-10  8:53 ` how can I skip globbing through SCCS subdirs? P.Stephenson
@ 1995-11-10 19:09   ` John S Cooper
  0 siblings, 0 replies; 2+ messages in thread
From: John S Cooper @ 1995-11-10 19:09 UTC (permalink / raw)
  To: P.Stephenson; +Cc: John S Cooper, Sam Falkner, Zsh users list

>> P Stephenson writes:

 Peter> This means you can exclude SCCS directories like this:
 Peter> ls **/*.c~(*/)#SCCS/*

 Peter> The (*/)# is a trick so that top level SCCS directories are
 Peter> ignored as well as any /SCCS/ bits in the middle somewhere.

Marvellous!  that seems to work great.

This also seems to be equivalent:

ls **/*.[ch]~**SCCS/*

Interestingly, using `time' indicates that the form above spends less
time in the system, but more time in user space.  (I ran the experiment
multiple times and the results below are pretty representative of a
rough average)

/bin/ls **/*.[ch]~**SCCS/*: 0.89s(r) 0.37s(u) 0.19s(s) (63%)

/bin/ls **/*.[ch]~(/*)#SCCS/*: 0.99s(r) 0.15s(u) 0.28s(s) (43%)

Should there be any performance difference between using **SCCS and
(/*)#SCCS ?


Is the exclusion pattern (to the right of the ~) evaluated once per file
that matches the left hand side, or is it evaluated for everything, and
then somehow merged with the output of the left side?

Would it be more efficient to narrow the scope of the exclusion by using
this?:

ls **/*.[ch]~**SCCS/*.[ch]

[ Again, please copy me on any replies, since I'm not on the alias ]

Thanks,

    --- John.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1995-11-10 20:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <199511100311.TAA07019@kontiki.Eng.Sun.COM>
1995-11-10  8:53 ` how can I skip globbing through SCCS subdirs? P.Stephenson
1995-11-10 19:09   ` John S Cooper

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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).