bugfindutils - Bugs: bug #34159, -path and -prune with -print and...

 
 

bug #34159: -path and -prune with -print and without have different result.

Submitted by:  Oleksandr Gavenko <gavenkoa>
Submitted on:  Sun 28 Aug 2011 10:45:38 PM UTC  
 
Category: findSeverity: 3 - Normal
Item Group: Wrong resultStatus: Invalid
Privacy: PublicAssigned to: Eric Blake <ericb>
Originator Name: Open/Closed: Closed
Release: 4.5.9Fixed Release: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed 31 Aug 2011 10:10:26 PM UTC, comment #3:

As surprising behavior I found in Emacs I file bug to it:

http://debbugs.gnu.org/cgi/bugreport.cgi?bug=9414

My suggestion is use '-type d' in directory exclude pattern:

$ find . '(' -type d -path '*/file' ')' -prune -o -type f -print

to fix original Emacs bug...

Oleksandr Gavenko <gavenkoa>
Mon 29 Aug 2011 01:18:22 PM UTC, comment #2:

Not a bug. -prune is documented as only having an action on directories, not regular files - so -prune does not trim files.

is strictly equivalent to:

-path '*/file' is true for dir/file, -prune is always true but has no effect, so the -o does not kick in, then the implicit -print prints the file name. Meanwhile:

is strictly equivalent to:

-path '*/file' is true, -prune is true and has no effect, so the -o does not kick in, and there is nothing left to -print the file name.

Eric Blake <ericb>
Project AdministratorIn charge of this item.
Sun 28 Aug 2011 10:53:38 PM UTC, comment #1:

$ find --version
find (GNU findutils) 4.5.9
Packaged by Cygwin (4.5.9-2)
Copyright (C) 2010 Free Software Foundation, Inc.

Oleksandr Gavenko <gavenkoa>
Sun 28 Aug 2011 10:45:38 PM UTC, original submission:

$ mkdir dir
$ touch dir/file
$ find . -path '*/file' -prune -o -type f
.dir/file
$ find . -path '*/file' -prune -o -type f -print
<nothing>

Emacs uses pattern

find . '(' -path '/dir1' -o ... -path '/dirn' ')' -prune -o -type f -name 'GLOB' -print0 | xargs -0 -nH grep 'REGEX'

for 'M-x rgrep' to exclude certain directories dir1...dirn (from 'grep-find-ignored-directories' variable).

As you can see from example if add -print/-print0 find can not find file with name same as in -path arg, but without can.

Oleksandr Gavenko <gavenkoa>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by ericb (Posted a comment)
  • -unavailable- added by gavenkoa (Submitted the item)
  • -unavailable- added by gavenkoa
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Mon 29 Aug 2011 01:18:22 PM UTCericbStatusNone=>Invalid
      Assigned toNone=>ericb
      Open/ClosedOpen=>Closed
    Sun 28 Aug 2011 10:45:38 PM UTCgavenkoaCarbon-Copy-=>Added -unavailable-

    Back to the top


    Powered by Savane 3.1-cleanup1