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

Discussion in 'Ruby' started by Matthew Denner, Aug 4, 2006.

  1. 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
     
    Matthew Denner, Aug 4, 2006
    #1
    1. Advertising

  2. Matthew Denner

    Guest

    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.

    --
    Nobu Nakada
     
    , Aug 4, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Georgy Pruss
    Replies:
    15
    Views:
    734
    Tim Roberts
    Dec 1, 2003
  2. Tim Peters
    Replies:
    1
    Views:
    367
    Duncan Booth
    Dec 1, 2003
  3. Sean Berry

    Question about glob.glob <--newbie

    Sean Berry, May 4, 2004, in forum: Python
    Replies:
    3
    Views:
    350
    David M. Cooke
    May 4, 2004
  4. Elbert Lev

    glob.glob unicode bug or feature

    Elbert Lev, Jul 31, 2004, in forum: Python
    Replies:
    5
    Views:
    404
    Neil Hodgson
    Aug 2, 2004
  5. Jim
    Replies:
    0
    Views:
    337
Loading...

Share This Page