Filter '.' and '..' from wglob results#152
Conversation
|
The amend commit is a much simpler and more correct solution than the first. Before we compared the final result. Now we compare each component before they get matched in This filter applies in more cases than the previous solution. |
|
Nope. Both solutions have glaring oversights. sorry about that. back to the drawing board. |
|
At this point im not confident that i have not overlooked something, but the last commit seems to really work this time. I think its about time to write a test... |
magicant
left a comment
There was a problem hiding this comment.
Thank you for the contribution!
For tests, see tests/path-p.tst, which contains test cases for checking POSIX-compliance of glob. You might also want to check tests/path-y.tst, which covers non-POSIX aspects of glob, but I think we will probably only need to add a test to the former.
|
Are you sure that tests for this belong in the posix category? |
You're right. Since the new behavior is not yet mandatory, the tests should be in path-y.tst. Thanks for pointing this out! |
|
I added a test case for the The test case for combined extendedglob and dotglob has a fairly long expected output (372 characters), it could perhaps be shortened a bit. |
magicant
left a comment
There was a problem hiding this comment.
Thank you. Can we mark the code "ready for review" now? It looks good to me.
|
Merged. Thank you so much! |
Addresses issue #97
Iterate over the results from
wglob_searchand remove any verbatim match of.and...NOTE: This does not apply to results like
component/..or recursive globs. This is a naive solution. Perhaps a more general solution could be done inwglob_search?I did a small optimization by conditionally stopping the loop as soon as two results are removed. This relies on the assumption that only two results from
glob_searchwould match.or...The filtering happens after the results are sorted, this likely limits the number of iterations, but this is another assumption.