On Wed, Apr 11, 2018 at 06:16:19PM +0300, Ilkka Virta wrote: > So, given > > . > |-- dir > | +-- link -> ../otherdir > +-- otherdir > +-- subdir > +-- foo > > (that is: mkdir -p dir otherdir/subdir; ln -s ../otherdir dir/link; touch > otherdir/subdir/foo ) > > dir/**/foo does not match anything, but dir/**/subdir matches > dir/link/subdir , i.e. ** looks through the link, but doesn't recurse > through it? Did I get that right? > > That does seem somewhat surprising. The documentation on globstar doesn't > seem to mention anything about behaviour re. symlinks either.
What I'm seeing is that **/file in my example, or dir/**/subdir in your example, acts as if a single * glob had been used. I.e. you get (dir/link/subdir) because dir/*/subdir would have matched that, and I get (dir/file link/file) because */file would have matched that. With just those two examples, it looks like ** tries to match like a regular * first, and then only tries recursion if that fails.