[Toybox] Towards find cleanup

Felix Janda felix.janda at posteo.de
Wed Apr 10 11:34:48 PDT 2013


Hi Tim,

thanks for your feedback.

On 04/10/13 at 11:12am, Tim Bird wrote:
> ...
> > 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.

POSIX says that -a is optional. Adding in "-a" does still not print
directories.

> 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.

Thanks for the debugging hints.

> > 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.

I'm looking forward it.

>  -- Tim

Felix



More information about the Toybox mailing list