Date: Mon, 23 Sep 2019 12:29:18 +0300
From: Ilkka Virta <[email protected]>
Message-ID: <[email protected]>
| (as well the standard '-depth', somewhat confusingly)
There is no real standard for this - NetBSD has deprecated the -depth
operator (which never really was one) and replaced it by a -d option
which makes much more sense (-depth never really was the right way to
do it). -depth (the old way) is still supported for compat with old
scripts, but is only mentioned in doc in the STANDARDS section, as:
Historically, the -d, -h, and -x options were implemented using the
primaries "-depth", "-follow", and "-xdev". These primaries always
evaluated to true, and always took effect when the expression was parsed,
before the file system traversal began. As a result, some legal
expressions could be confusing. For example, in the expression "-print
-or -depth", -print always evaluates to true, so the standard meaning of
-or implies that -depth would never be evaluated, but that is not what
happens; in fact, -depth takes effect immediately, without testing
whether -print returns true or false.
What I think is the purpose of poor choice of an option, the FreeBSD -depth N
is done using -maxdepth and -mindepth in combination (using the same value).
(That is, to select a depth of exactly N, one requests a depth of no less
than N and no more than N (where N, if signed, has the usual meaning, of
course).
Either way (as "-depth N", or "-mindepth N -maxdepth N") this is an operator
that applies to each path element encountered, so makes sense to have as
an element of the find expression (unlike the old -depth which does not.)
I'd strongly suggest not using examples of anything using "-depth" - choose
some other example instead.
kre