bugfindutils - Bugs: bug #59012, find examples wrong in man page

 
 

bug #59012: find examples wrong in man page

Submitter:  None
Submitted:  Tue 25 Aug 2020 09:33:26 PM UTC
   
 
Category:  documentation Severity:  3 - Normal
Item Group:  None Status:  Fixed
Privacy:  Public Assigned to:  berny
Originator Name:  Nils Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  4.6.0
Fixed Release:  4.8.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Wed 16 Sep 2020 10:43:50 PM UTC, comment #2: 

Thanks for the suggestion.  The attached patch makes the quoting more consistent in that example.  Pushing soon.

(file #49800)

Bernhard Voelker <berny>
Group administrator
Tue 25 Aug 2020 09:41:34 PM UTC, comment #1: 

Well, after reading it a second time, the result is not that wrong as expected. Maybe its a little bit confusing that the result is not printed instad just one sentence explains what happens. To make the example more clear maybe the exact output should be written.

Nevertheless a consitent quoting of {} should be used.


Anonymous
Tue 25 Aug 2020 09:33:26 PM UTC, original submission:  


> find repo/ \( -exec test -d '{}'/.svn \; -or \
> -exec test -d {}/.git \; -or -exec test -d {}/CVS \; \) \
> -print -prune
>
>Given  the  following  directory of projects and their associated SCM administrative directories, perform an efficient search for the projects' roots:
>
> repo/project1/CVS
> repo/gnu/project2/.svn
> repo/gnu/project3/.svn
> repo/gnu/project3/src/.svn
> repo/project4/.git
>
>In this example, -prune prevents unnecessary descent into directories that have already been discovered (for  example  we do not  search project3/src because we already found >project3/.svn), but ensures sibling directories (project2 and >project3) are found.



The above example from the find man page (from find (GNU findutils) 4.6.0.225-235f) is not producing the listed output.
As the matching is performed on the directory name plus an extention using -exec test '{}'/.svn the matching directory would be e.g. repo/project2 which is giving a positive test on execution of test repo/project2/.svn. Therefore find is printing only "repo/project2" (and not "repo/project2/.svn")

As -prune is used project3 is matching and therefore no descending into it will be done. Based on this the sub folder src inside project3 can never be found even though it also conatins a .svn folder.

The example is inconsitent in using quotations for the -exec action. in the first exec action '{}' is used while in the second and third just {} is used.


Giving the folloing driectory tree:
./gnu
./gnu/project2
./gnu/project2/.svn
./gnu/project2/.svn/foobar
./gnu/project2/.svn/pristine
./gnu/project2/.svn/wc.db
./gnu/project3
./gnu/project3/src
./gnu/project3/src/debug_out
./gnu/project3/src/.svn
./gnu/project3/src/.svn/pristine
./gnu/project3/src/.svn/wc.db
./gnu/project3/.svn
./gnu/project3/.svn/barfoo
./gnu/project3/.svn/wc.db
./project1
./project1/CVS
./project1/CVS/foo
./project1/CVS/fooabr
./project4
./project4/foobar
./project4/.git
./project4/.git/bakcup
./project4/.git/wb.git
./project4/test

The output of the example find produces the follwoing (expected) output which is different from the documented example:

user@host:~/repo$ find ./ \( -exec test -d '{}'/.svn \; -or -exec test -d '{}'/.git \; -or -exec test -d '{}'/CVS \; \) -print -prune
./project4
./project1
./gnu/project3
./gnu/project2


Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #49800:  0001-find.1-use-consistent-quoting-in-example.patch added by berny (1KiB - text/x-patch - [PATCH] find.1: use consistent quoting in example)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by berny (Updated the item)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-01-09 berny Open/ClosedOpen Closed
        Fixed ReleaseNone 4.8.0
    2020-09-22 berny StatusCode Review Fixed
    2020-09-16 berny Attached File- Added 0001-find.1-use-consistent-quoting-in-example.patch, #49800
        StatusNone Code Review
        Assigned toNone berny

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code