[bug #62259] find(1) manpage prune example error

raf <[email protected]>
Newsgroups gmane.comp.gnu.findutils.bugs
Message-ID <[email protected]>
Follow-up Comment #2, bug #62259 (project findutils):

Another (unrelated) problem with this example is that it is supposed to be "an
efficient search for the projects' roots", but it's not efficient (apart from
the pruning). It invokes up to three test processes for every candidate file.
It only needs to invoke a single test process (that checks for all three SCM
sub-directories), and it only needs to do that for candidates that are
actually directories. It's doing it for everything. That's a lot of
unnecessary processes.

I suggest replacing this:

    $ find repo/ \
        \( -exec test -d '{}/.svn' \; \
        -or -exec test -d '{}/.git' \; \
        -or -exec test -d '{}/CVS' \; \
        \) -print -prune

with this:

    $ find repo \
        -type d \
        -exec test -d '{}/.svn' -o -e '{}/.git' -o -d '{}/CVS' \; \
        -print -prune

Bonus: The -e for {}/.git rather than -d is because .git can be a file that
refers to a directory somewhere else.


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?62259>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.