bug-findutils
[Top][All Lists]
Advanced

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

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


From: raf
Subject: [bug #62259] find(1) manpage prune example error
Date: Fri, 8 Apr 2022 08:30:42 -0400 (EDT)

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/




reply via email to

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