Fixing some exclude/include bugs

Donovan Baarda abo at
Wed Apr 23 14:36:58 EST 2003

On Wed, 2003-04-23 at 04:48, Wayne Davison wrote:
> The remaining bug I didn't fix (yet):
>  - The presence of a "**" turns all "*"s into "**"s.
> Fixing this last bug would require either switching to a new wildcard-
> matching routine (like the one I posted a while back), or switching to
> using regular-expression matching and converting wildcard strings into

I did exactly this in Python for something I was working on. There are a
few tricks to watch out for, but the attached python implementation
should translate into C fairly easily.
I also have Python implementations of efficient directory scanning and
filename matching against include/exclude lists if anyone is interested.

> regex strings.  I'm thinking that it might be nice to go the regex route
> and add an option to allow the user to specify all exclude/include
> strings as regular expressions instead of wildcard strings.

> Comments?

I like the "extended shell pattern" matching. It is a logical extension
of shell patterns that is simple but quite powerful for the specific
task of filename matching. I also love regex's because you can do damn
near anything with them, particularly perl-style regex's. 

However, I think regex's are overkill for most filename matching, and
they are not a perfect fit for the application. Common chars like '.'
have a special meaning, and common desired matches are verbose to
express, ie '[^/]' for "all but slash". You could modify the regex
syntax to make it more "filename friendly", but you are making work for
everyone implementing, supporting, documenting and learning the

Changing the matching implementation to use regex's does make it simple
to add the option of using of regex's at the command line, but I would
keep the efnmatch matching as the default.

Donovan Baarda      
-------------- next part --------------
A non-text attachment was scrubbed...
Type: text/x-python
Size: 2796 bytes
Desc: not available
Url :

More information about the rsync mailing list