In article <4595675.4...@PointedEars.de>,
Thomas 'PointedEars' Lahn <use...@PointedEars.de> wrote:
>Alan Curry wrote:
>
>> Thomas 'PointedEars' Lahn <use...@PointedEars.de> wrote:
>>
>> If you hadn't started with "No", I wouldn't think you were contradicting
>> me. Where's the conflict between what you wrote and what I wrote? I see no
>> errors in either (except the misspelled "short-circuit") and have no idea
>> why you chose to inject this idiot-level lecture on "." and ".."
>
>The reason that `.' is found (and need _not_ be found *first* as you
>claimed) is _not_ (as you claimed) that the first positional argument is
>`.', but that `-name .' descends into the directory named `.' *in* `.'
>(`./.', which is of course equivalent to `.').
Well now at least I can see the difference between what you wrote and what I
wrote. Luckily for me your assertion is wrong.
>>
>> This also doesn't conflict with what I said. Do you object to my
>> description of this as the "first file to be tested"? I stand by that. The
>> paths given to find as search start points *are* tested against the
>> predicates,
>
>Evidentially, for the -name predicate they are not (for that would be
>superfluous if the paths were only `.', and error-prone if they were not).
>Only the files that the directories specified by the paths *contain* are
>tested with -name, of course. One of those files is `.' first-level in each
>path.
You've stated a testable hypothesis. This is good. In your theory of
operation, find will always find something to match "-name ." under the
starting directory. In my theory of operation, "-name ." will only match if
"." is actually given as an argument.
$ mkdir /tmp/emptydir
$ cd /tmp/emptydir
$ mkdir foo bar
$ find foo -name . -prune -print
$ find foo -name foo -prune -print
foo
$ find * -name . -prune -print
$ find * -name foo -prune -print
foo
$
The test shows that my theory was correct. When "." appears among the
arguments to find, the string "." is matched against the -name pattern. When
something else is given as an argument, that something is matched against the
-name pattern.
An addition to the experiment:
$ touch baz
$ find * -name 'ba*' -prune -print
bar
baz
$
The arguments given to find to start the search (here, a * which expands to the
3 arguments foo bar baz) are tested against the -name predicate and the ones
that match are passed through to -print. One of them is a directory, the
other one isn't. The -name predicate doesn't care about the difference
because it just matches the filename string against the pattern.
In conclusion: "find . -name ." does indeed match the . because it begins the
search by testing the first name in the path-list (in this case ".") against
the predicates.
--
Alan Curry