wildcards

Dave Dykstra dwd at bell-labs.com
Mon May 13 08:37:01 EST 2002


On Fri, May 10, 2002 at 11:35:24AM -0700, Wayne Davison wrote:
> On Fri, 10 May 2002, Dave Dykstra wrote:
> > If you dynamically created a */*/*/foo/* pattern with the number of */
> > to match the current path it would only have to call fnmatch once.
> 
> That's assuming the pattern doesn't contain an interior/trailing "**"
> (which could only use the try-after-each-slash loop).  Also, there's no
> need to tweak the pattern -- it would be the same amount of work to just
> figure out where in the filename your prefix of "*/*/*/" represents and
> match at that position (since we'd have to count slashes anyway).

Right, that would be simpler.

> We'd
> also have to be careful to ensure that there aren't any exceptional
> patterns that could lead to problematical positioning.
> 
> A useful question at this point would be:  Does the extra complexity
> make a big enough difference to be worth it?  With all of the file I/O
> going on, I'm wondering if it would even be noticed.

I guess I wasn't thinking that it would be extra complex, although I
probably just haven't envisioned your suggested solution properly.  I am
concerned that if somebody has lots of wildcard patterns it could become a
waster of processor time.  On the other hand, since we're talking about
patterns that stop at slashes I suppose an fnmatch() call won't take very
long before it finds out whether or not a match has occurred.   It does
seem a shame to check those patterns all the way down the path, though,
especially since the recursive directory traversal means that the same
patterns would already have been checked against the beginning of the path
as an earlier pathname.  I suggest you go ahead and code it in the way you
think would be simplest and then we can evaluate it more concretely.

- Dave




More information about the rsync mailing list