Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

symlinks are not followed since 4.0.6? #134

Closed
seanmwalker opened this issue Nov 19, 2014 · 7 comments
Closed

symlinks are not followed since 4.0.6? #134

seanmwalker opened this issue Nov 19, 2014 · 7 comments

Comments

@seanmwalker
Copy link

We have been leveraging glob to follow symlinks to list all files within a given path, and that had worked great until Monday when 4.1.0 came out.

For instance a pattern of '~/myProject/*/' would contain a mixture of folders, files and symlinked folders in the myProjects folder. We see the symlink itself in the list of file paths returned, but none of the child files from the location the symlink is pointing to are shown with the new versions of glob.

It looks like this may be happening on line 370 of glob.js

if (lstat.isSymbolicLink()) {
  //console.error('SYMLINK %j', abs)
  self._stat(abs, function (er, stat) {
    return cb(null, stat === 'DIR' ? [] : null)
  })

Was this change to stop following symlinks intended, and if so is there an option planned that will re-enable this feature?

@isaacs
Copy link
Owner

isaacs commented Nov 19, 2014

Symlinked directories are no longer explored. This is the same behavior as Bash 4.3. If you find a case where it doesn't behave the same as Bash 4.3, then please let me know. Otherwise yes, this is by design. See the discussion in #86

@isaacs isaacs closed this as completed Nov 19, 2014
@isaacs
Copy link
Owner

isaacs commented Nov 19, 2014

If you rely on this behavior you should pin your glob dependency version at 3.x. This change was introduced in 4.0.

@nathanjessup
Copy link

I'm also having trouble with this change, and I don't believe it matches the behavior of bash 4.3 either. How did you test against Bash's behavior? Below is a quick example of how globstar functions for me in bash 4.3.30.

Pastebin with a demo of how bash 4.3 is handling symlinks: http://pastebin.com/YAq8wQyK

@isaacs
Copy link
Owner

isaacs commented Nov 19, 2014

Indeed, you've found a discrepancy between bash 4.3 and node-glob! This is a bug! Posted as #135

The solution is not "follow symlinked dirs" as suggested in the OP here. The correct behavior is "stop following symlinked dirs as part of a globstar match, but still resolve their contents against subsequent parts of pattern".

@clintwood
Copy link

@isaacs so the follow option in the readme is incorrect?

Feature Request: It would be really great to be able to override the Bash 4.3 compliance of not following globstar symlinks! The option is there and it looks like a simple test for that option here could turn this back on! Is this a possibility?

@isaacs
Copy link
Owner

isaacs commented Sep 15, 2015

@clintwood Yes, in the latest release you can do {follow: true} in the options, and it'll happily go along until it gets an ELOOP error from the fs.

@clintwood
Copy link

Ahh, great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants