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

M

Matthew Denner

Hi,

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

I have read http://groups.google.com/group/comp...ed512?lnk=st&q=&rnum=1&hl=en#e9bc0579939ed512
in which the reply says:

"**" doesn't traverse symbolic links, or it can cause an infinite loop.

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 (http://svk.elixus.org/) 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.

Matt
 
N

nobu

Hi,

At Fri, 4 Aug 2006 22:54:00 +0900,
Matthew Denner 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,831
Latest member
HealthSmartketoReviews

Latest Threads

Top