Behaviour of Dir.glob("**/b") and Dir.glob("*/b") for symlin


Why is it that Dir.glob(“*/b”) will follow a symlinked directory but
Dir.glob(“**/b”) will not?

I have read
in which the reply says:

“**” doesn’t traverse symbolic links, or it can cause an infinite

Ok, sure, someone could do:

mkdir a/b
ln -s …/…/a a/b/c

So as to create a symlink from ‘a/b/c’ back to ‘a’ which would cause
infinite recursion, but then this is their own stupid fault IMO! I
really don’t see that this is a justifiable reason for this and, if it
is, then why isn’t there a flag that can be passed that’ll allow
people to say “follow symlinks for **”.

The reason I ask this is because I do alot of my development
(Ruby-on-Rails) offline so use SVK ( which
doesn’t support the ‘svn:externals’ property. Because of this I make
symlinks from my ‘vendor/plugins’ directory to other SVK checked out
directories. All this works (I think) fine when running the
application but doesn’t add things like generators provided by plugins
like Rails Engines. This is because the code looking for the
generator uses Dir[‘vendor/plugin/**/generators’].

Now, it could be argued that this is a problem for Rails to do (to
standardise the locations of these generators) but I personally want
to understand whether this decision not to follow symlinks is purely
because of my contrived example above.


1 Like


At Fri, 4 Aug 2006 22:54:00 +0900,
Matthew D. wrote in [ruby-talk:206260]:

Why is it that Dir.glob("*/b") will follow a symlinked directory but
Dir.glob("**/b") will not?

Dir.glob("/*//b") will follow a symlink up to once.