On Tue, Sep 12, 2023 at 10:15 AM <crs...@libero.it> wrote:
>
> Let's assume the following current folder:
>
> .
> |
> +---- a.txt
> |
> +---- b.txt
> |
> +---- c.txt
>
> in which we issue the following command
>
> $ find . -depth -name a.txt -o -name b.txt
>
> We get the following result:
>
> ./a.txt
> ./b.txt
>
>
> -------- Problem 1 --------
>
> By evaluating the expression according to the information in the manual of 
> find
> the command should return also c.txt as part of the result. Let me explain my
> reasoning. The above command is equivalent to the following command:
>
> $ find . -depth -a -name a.txt -o -name b.txt
>
> and the expression is evaluated for each file, that is even for c.txt and 
> because
> the result is known immediately after the evaluation of -depth (which always 
> returns
> true) the command should print it to the standard output.
>
> Not having c.txt in the result it seems to me that find performs the following
> evaluation:
>
>      $ find . -depth -a \( -name a.txt -o -name b.txt \)
>
> Is this correct? If so, then some information in the manual page should 
> clarify
> that all global options are (probably) evaluated only once and before the 
> rest of
> the expression.

No, that's not correct.  The behaviour is like

    $ find . \( -depth -a -name a.txt \) -o -name b.txt

-depth is always true, but "true and something else" is the same as
"something else" so it still has to check -name a.txt.

-- 
Tavian Barnes

Reply via email to