[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFC: "-contains" option

From: Eddie Kohler
Subject: Re: RFC: "-contains" option
Date: Sat, 21 Feb 2009 15:25:40 -0800
User-agent: Thunderbird (X11/20090105)

James Youngman wrote:
On Sat, Feb 21, 2009 at 10:23 PM, Eddie Kohler <address@hidden> wrote:
exclude=$(find . -name .find-ignore -printf '%h\n' | sort -u); find . \! \(
-false $(for e in $exclude ; do printf ' -o -name "%s" ' $e; done) \) ,
-true > /dev/null
  => 3.06s

There is a -prune missing from both find expressions there I think.
The first can be pruned because once we find a .find-ignore file we
don't need to search for more .find-ignore files in subdirectories.
The second needs a -prune because that's the point of putting the
.find-ignore file there.

I purposefully left off -prune from all expressions, including the -contains
one, so as to test only match overhead.

And how could you use -prune in the first expression?

>> exclude=$(find . -name .find-ignore -printf '%h\n' | sort -u)

By the time you have found the .find-ignore file it is too late to prune, you
are already in the directory.  Depending on how the directory's entries are
ordered you may have already gone through the subdirectories!

It's fair to say I think that my concern around -contains has to do
with the fact that it seems to be an extra feature designed for only
one use case.   I avoid adding new features which only have limited or
special-case uses.

Can you think of a more generally useful (i.e. more generic) feature
which might also lend itself to your problem?

Well I'll think about this, but I don't think -contains is special purpose.
A combined "-contains -prune" would only satisfy my use case, but as
defined in the patch, "-contains" is a test, and can be used in many
ways.  For instance here is a find of all directories containing a given file:

find . -contains file -print

All directories containing either file1 or file2:

find . \( -contains file1 -o -contains file2 \) -print

Of course these could be written in other ways now, but more obscurely.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]