-
-
Notifications
You must be signed in to change notification settings - Fork 480
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
Globbing a symlink cycle never returns #86
Comments
👍 |
Works for me.
Do you have a test case? |
Any puppet module with tests, for example https://github.com/kietsy/kietsy-tinc In that repo after initializing the test infrastructure
So the problem is not an infinite loop, but rather that node-glob should stop at |
Hm. So, shell globbing doesn't "only give you unique files", nor does it "not follow symlinks". Example:
Note that symbolic links ARE being followed by It seems, however, that it does not explore symbolic links that reference a path portion of the current path to the symbolic link itself. So, even though Furthermore, this The crash that you're seeing is happening because there are a large number of recursive symbolic links, rather than a particularly deep set of them, so you're hitting the memory limit before hitting the ECYCLE error from the fs. Updating to Bash 4.3-style behavior would fix the problem. |
It's actually crashing because of the large set of redundant results. There is just one symlink.
I used this script
and the tab completion of either bash or zsh as a reference and compared it to node-globs behaviour. This gist illustrates two cases, yours above and mine for a puppet module with one dependency. As one can see, the current shell globbing outputs each file only once, if there is another path to the same file it's omitted in the results. Don't know if it's always been like this, I can only test it with zsh 5.0.7 and bash 4.3.030 (oh and I just noticed that the script does not work with bash since tab globbing does not seem to be supported for bash, it just replaces the |
Your test is interesting, but non-authoritative. The reference implementation that node-glob targets is bash 4's globstar and extglob behavior. The example I posted above does show that Bash 4.1 and Bash 4.3 have different behavior, and it seems that Bash 4.3's globstar behavior is superior, so that's what we should target. It doesn't matter what zsh or tab-completion do, ultimately, though this is one example of a use-case where the more "conservative" results are much more useful. |
You're right, I didn't grasp everything in your comment at first. Adopting the bash4.3 globstar behavior would fix this (and would actually matches the one from zsh). Just to be sure, the command |
No, I don't have bash 4.1 installed any longer (upgraded due to shellshock some time ago). But if I re-generate the test fixtures with bash 4.3, I see different results. So, yeah, we're doing the wrong thing now (but only because "the right thing" changed!) |
Here's the diff in the test fixture results from bash 4.1 (used to generate them originally) and bash 4.3 (which I have now) https://gist.github.com/isaacs/f748618f744f61756f55 |
So, it seems like the behavior can be summed up as: "While expanding matches for a This, of course, is after consecutive |
👍 Yep, if adopting bash's new behavior is OK for you that would be great. It would suffice my use case and probably the other two's referenced above as well. |
Landed in 4.0, made MUCH faster in 4.1. |
keeps globbing...
The text was updated successfully, but these errors were encountered: