[Toybox] Towards find cleanup

Tim Bird tim.bird at am.sony.com
Wed Apr 10 11:12:40 PDT 2013


On 04/10/2013 10:41 AM, Felix Janda wrote:
> Hello,
> 
> attached is some cleanup of the find toy inspired by Rob's (very cool)
> mails on how he proceeds when cleaning up toys. (and Isaac's recent
> partial cleanup of xzcat)
> 
> The patch contains a commit message.
> 
> The cleanup was mainly mechanical and I still don't understand the toy
> well. (Before and after the cleanup) there seems to be a problem with
> the rule parsing/interpretation. For example
> 
> find . \( -type f -type f \) -o -type d
> 
> does not print directories.

Hmmm.  I'm not sure that's a legal filter expression.  what is
"-type f -type f"?  Is there supposed to be an operator (-a or -o)
in there?

In general, regular find may be a little more liberal interpreting
filter expressions than the find toy.  I think that regular find
will often imply an 'and' when no operator is specified.  I considered
this for the find toy, but didn't want to gum up the parser with weird
handling.  I know that lots of times people do things like string a bunch
of filters together without 'and's, like so:
find . -type f -name "*.o" -mtime -20

These types of sequential and's ought to be supported.  But allowing
for unspecified 'and's in weird places in a complex parse expression
seems like overkill for a toy.

There used to be debug code in the find toy to dump the expression tree,
but Rob removed it.  (I'm not complaining, I think the code should have
been removed eventually).  To debug this, please use a debugger to make
sure the filter expression tree matches what you think it should be based
on the command line, then verify that the actually filtering (expression
evaluation) proceeds as desired.

With the missing operator between '-type f' and '-type f' above, I'm not
even sure what the desired expression is.

> The toy also does not follow the whitespace conventions in toybox. But I
> think that someone has scripts lying around to fix that.
> 
> I think that some function parameters should be made const and that
> the code could be made less repetitive. 

Thanks very much for working on this.  I haven't had time to look
at it myself, and I'm very glad to see someone taking it up. :-)
'find' is one of the most significant omissions in toolbox, and one
of the most useful things to have in the toy arsenal (IMHO).

I'll send some comments on the patch in another mail.
 -- Tim

=============================
Tim Bird
Architecture Group Chair, CE Workgroup of the Linux Foundation
Senior Staff Engineer, Sony Network Entertainment
=============================


 1365617560.0


More information about the Toybox mailing list