zsh-users
 help / color / mirror / code / Atom feed
* Excluding files in CVS directories in filename generation
@ 2003-12-08 17:11 Hannu Koivisto
  2003-12-08 17:29 ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Hannu Koivisto @ 2003-12-08 17:11 UTC (permalink / raw)
  To: Zsh Users' List

Greetings,

If I want a pattern that matches all files in the current directory
and its descendant directories excluding files in directories named
CVS, why doesn't

**/*~**/CVS/*(.)

work?  Files in "$(pwd)/CVS" are not excluded with that pattern and
instead I have to say

**/*~CVS/*~**/CVS/*(.)

which feels a bit too verbose.  Any solutions?

-- 
Hannu


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

* Re: Excluding files in CVS directories in filename generation
  2003-12-08 17:11 Excluding files in CVS directories in filename generation Hannu Koivisto
@ 2003-12-08 17:29 ` Peter Stephenson
  2003-12-08 17:36   ` Hannu Koivisto
  0 siblings, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2003-12-08 17:29 UTC (permalink / raw)
  To: Zsh Users' List

Hannu Koivisto wrote:
> Greetings,
> 
> If I want a pattern that matches all files in the current directory
> and its descendant directories excluding files in directories named
> CVS, why doesn't
> 
> **/*~**/CVS/*(.)
> 
> work?  Files in "$(pwd)/CVS" are not excluded with that pattern and
> instead I have to say
> 
> **/*~CVS/*~**/CVS/*(.)

Yes, indeed.  Luckily, you can do:

(^CVS/)#*(.)

This is the more general form of ** --- the pattern in the parentheses
is used (here anything but the string CVS) instead of a `*' to match
directory names.  More precisely,
  **/
  (*/)#
are equivalent.  That's why you don't need another / after the parentheses.

You need extended_glob, but you must already have it set in this case.

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: Excluding files in CVS directories in filename generation
  2003-12-08 17:29 ` Peter Stephenson
@ 2003-12-08 17:36   ` Hannu Koivisto
  2003-12-08 17:43     ` Peter Stephenson
  2003-12-08 18:14     ` Pavol Juhas
  0 siblings, 2 replies; 5+ messages in thread
From: Hannu Koivisto @ 2003-12-08 17:36 UTC (permalink / raw)
  To: Zsh Users' List

Peter Stephenson <pws@csr.com> writes:

> Yes, indeed.  Luckily, you can do:
>
> (^CVS/)#*(.)
>
> This is the more general form of ** --- the pattern in the parentheses
> is used (here anything but the string CVS) instead of a `*' to match
> directory names.  More precisely,
>   **/
>   (*/)#
> are equivalent.  That's why you don't need another / after the
> parentheses.

Excellent, thanks!  I was aware of the general form but couldn't
think of actually using it to solve this problem :)

I would be interested to know why **/*~**/CVS/*(.) didn't work,
though.

-- 
Hannu


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

* Re: Excluding files in CVS directories in filename generation
  2003-12-08 17:36   ` Hannu Koivisto
@ 2003-12-08 17:43     ` Peter Stephenson
  2003-12-08 18:14     ` Pavol Juhas
  1 sibling, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2003-12-08 17:43 UTC (permalink / raw)
  To: Zsh Users' List

Hannu Koivisto wrote:
> I would be interested to know why **/*~**/CVS/*(.) didn't work,
> though.

Ah, yes, it's not completely obvious.  It's because /'s after the ~
aren't special, and hence neither is **/.  So in fact it is looking for
the pattern `*/CVS/*' and trying to remove that, which doesn't occur.
You would need **/*~(*/|)CVS/*(.)

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.

www.mimesweeper.com
**********************************************************************


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

* Re: Excluding files in CVS directories in filename generation
  2003-12-08 17:36   ` Hannu Koivisto
  2003-12-08 17:43     ` Peter Stephenson
@ 2003-12-08 18:14     ` Pavol Juhas
  1 sibling, 0 replies; 5+ messages in thread
From: Pavol Juhas @ 2003-12-08 18:14 UTC (permalink / raw)
  To: Zsh Users' List

On Mon, Dec 08, 2003 at 07:36:30PM +0200, Hannu Koivisto wrote:
> Peter Stephenson <pws@csr.com> writes:
> 
> > Yes, indeed.  Luckily, you can do:
> >
> > (^CVS/)#*(.)
> >
> > This is the more general form of ** --- the pattern in the parentheses
> > is used (here anything but the string CVS) instead of a `*' to match
> > directory names.  More precisely,
> >   **/
> >   (*/)#
> > are equivalent.  That's why you don't need another / after the
> > parentheses.
> 
> Excellent, thanks!  I was aware of the general form but couldn't
> think of actually using it to solve this problem :)
> 
> I would be interested to know why **/*~**/CVS/*(.) didn't work,
> though.

The exclusion pattern after ~ does not treat "/" or "**/" specially.  As
far as I understand, the pattern is then used in the same way as for
string matching.  So if **/* generates CVS/Entries, it is not excluded,
because [[ CVS/Entries != **/CVS/* ]] .  To exclude the CVS directory
and all files below, you can use **/*~(*/)#CVS(/*)# Another way is
**/*~*CVS* , however this would also exclude filenames that contain
"CVS" string (e.g., aCVSb or CVS1/file).

HTH,

Pavol


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

end of thread, other threads:[~2003-12-08 18:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-12-08 17:11 Excluding files in CVS directories in filename generation Hannu Koivisto
2003-12-08 17:29 ` Peter Stephenson
2003-12-08 17:36   ` Hannu Koivisto
2003-12-08 17:43     ` Peter Stephenson
2003-12-08 18:14     ` Pavol Juhas

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