Re: clarification regarding the evaluation of global options
| Newsgroups | gmane.comp.gnu.findutils.bugs |
|---|---|
| Message-ID | <[email protected]> |
Tavian Barnes wrote: > On Tue, Sep 12, 2023 at 10:15 AM <[email protected]> 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. > Very correct. It is more than obvious that my question/interpretation was wrong. Probably because my reasoning was blurred by some of my expectations... Sorry for disturbing with non-problems. Thanks again Cristian