bugfindutils - Bugs: bug #17587, print0 action causes false results...

 
 

bug #17587: print0 action causes false results to be printed

Submitter:  None
Submitted:  Fri 01 Sep 2006 07:23:05 PM UTC
   
 
Category:  find Severity:  3 - Normal
Item Group:  Wrong result Status:  Invalid
Privacy:  Public Assigned to:  jay
Originator Name:  Saku Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  4.2.27
Fixed Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 15 Oct 2006 12:18:00 PM UTC, comment #2: 

This is how find is supposed to work.

James Youngman <jay>
Group administrator
Sat 02 Sep 2006 08:05:12 AM UTC, comment #1: 

Hello,
as you already guessed this is no bug.

<quote>
The expression is made up of options (which affect overall operation rather than the processing of a specific file, and always return true), tests (which return a true or false  value),  and actions  (which  have  side effects and return a true or false value), all separated by operators.  -and is assumed where the operator is omitted.

If the expression contains no actions other than -prune, -print is performed  on  all  files  for  which  the expression is true.
<unquote>

So the whole thing is depending on the order the options, tests and commands are specified.

-------------------
metzler@argenau:/tmp/findtest$ echo blah > notempty ; touch empty
ametzler@argenau:/tmp/findtest$ find -size 0 -print
./empty
ametzler@argenau:/tmp/findtest$ find -print -size 0
.
./notempty
./empty
ametzler@argenau:/tmp/findtest$ find -print -size 0 -print
.
./notempty
./empty
./empty
-------------------

The second command FIRST prints all entries and afterwards checks their size (and does nothing with result of the test as there is no action specified and because the commandline already contains an action, the "-print"). The first command does what you wanted it to do.

The third one illustrates the point, it prints all entries, then checks the size and prints the entries with size=0.

hth, cu andreas

Andreas Metzler <ametzler>
Fri 01 Sep 2006 07:23:05 PM UTC, original submission:  

This was discovered in combination with -size test but after some tests it proved to be there with other tests as well (-name).

I actually wonder if this is indeed a bug because it is too obvious to have been ignored or not reported so far...

So the case is that

find . -size 0

finds nothing in the current directory.

find . -print0 -size 0

accepts everything as a correct match. As if

find . -print0

was invoked.

Hopefully I am not reporting something silly here.

Thanks.

Anonymous

 

(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

 

CC list is empty

 

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 4 latest changes.

Date Changed by Updated Field Previous Value => Replaced by
2006-10-15 jay StatusNone Invalid
    Assigned toNone jay
    Open/ClosedOpen Closed
2006-09-01 None Carbon-Copy- Added -unavailable-

Back to the top

Powered by Savane 3.13-d3ae.
Corresponding source code