bugfindutils - Bugs: bug #50835, -print0 causes all files to be...

 
 

bug #50835: -print0 causes all files to be output

Submitter:  George Gonzalez <ggonzalez>
Submitted:  Thu 20 Apr 2017 03:40:47 PM UTC
   
 
Category:  find Severity:  3 - Normal
Item Group:  None Status:  Duplicate
Privacy:  Public Assigned to:  None
Originator Name:  ggonzalez Open/Closed:  Closed
Release:  4.5.11 Fixed Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Thu 20 Apr 2017 06:19:49 PM UTC, comment #1: 

Your complaint is the same as in bug 50780. Quoting from my response there, with a tweak of -printf changed to -print0:

When two expressions are written as 'A B', find behaves if you had instead written 'A -a B'. The -a operator is short-circuiting: if expression A returns false, expression B is not attempted; but if expression A returns true, then expression B is used.

When you write -print0 first, it always executes (everything gets printed), then you filter out the files, but do nothing further with the files you filtered.

When you write -print0 second, it only executes on the files that got past the -type filter.

Eric Blake <ericb>
Group administrator
Thu 20 Apr 2017 03:40:47 PM UTC, original submission:  

We run these commands:
Here=/etc

find "$Here"   -perm /u=x,g=x,o=x   -type f   >/tmp/allbins

find "$Here"   -perm /u=x,g=x,o=x   -type f -ls   >/tmp/allbins-ls

find "$Here"  -print0    -perm /u=x,g=x,o=x   -type f   >/tmp/allbins-z

wc -l /tmp/allbins

wc -l /tmp/allbins-ls

cat /tmp/allbins-z | tr '\0' '\n' | wc -l


The output is:

$ sudo bash t.sh
101 /tmp/allbins
101 /tmp/allbins-ls
3779

.... So it looks like there are 3779 files listed when we ask for -print0.
A quiick perusal using :  cat /tmp/allbins-z | tr '\0' '\n'   shows:

/etc
/etc/fstab
/etc/crypttab
/etc/mtab
/etc/resolv.conf
/etc/fonts
/etc/fonts/conf.d
/etc/fonts/conf.d/65-0-lohit-tamil.conf
/etc/fonts/conf.d/59-liberation-mono.conf
/etc/fonts/conf.d/66-ucs-miscfixed.conf
/etc/fonts/conf.d/59-liberation-sans.conf

.. all of which are not type f or mode executable


This sure looks like a bug!

Regards,


George



George Gonzalez <ggonzalez>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by ericb (Posted a comment)
  • -email is unavailable- added by ggonzalez (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 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-04-20 ericb Item GroupWrong result None
        StatusNone Duplicate
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-5190.
    Corresponding source code