[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
clarification regarding the evaluation of global options
From: |
crstml |
Subject: |
clarification regarding the evaluation of global options |
Date: |
Tue, 12 Sep 2023 14:54:17 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0 SeaMonkey/2.53.3 |
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.
-------- Problem 2 --------
I've tried to use "-D tree" to see that is going on. The first section shows:
Predicate List:
[(] [-depth] [-a] [-name] [-o] [-name] [)] [-a] [-print]
I deduce that before printing "Predicate list" section find elaborates the
expression
and adds a "-print". Correct. But, in this printed form the order of evaluation
has the same problems as mentioned in the section "Problem 1" above. The same
is true
for the next sections "Normalized Eval Tree", "Optimized Eval Tree", etc.
Thank you
Cristian
- clarification regarding the evaluation of global options,
crstml <=