-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
negative matches problem for .min.js like paths #65
Comments
I have a silimar issue, possibly related:
So the second pattern is a negation of the first one, but they both match! This is madness. |
I spotted this in your unit tests:
I checked this pattern and it found some problems:
This is NOT expected behaviour. |
This is also very, very strange:
They should all return false. |
👍 |
Same issues here. Please fix |
There are three things going on here. First of all, I think that "negated patterns" is just really problematic to reason about. I'd like to deprecate the feature, for the same reason that it was deprecated in node-glob, and replaced with an explicit set of "ignore" patterns. (You can of course do Specifically, this is problematic because it means that extglob patterns like The first tricky thing about doing that here is that it means reviewing how that is used in The second tricky thing about deprecating negation is that, like we did with When running without negation enabled (that is, with The second issue is that we're being a little overly aggressive in the negative extglob patterns. So, for example, a pattern like The third issue I'm seeing is that negative extglobs like $ [[ foo.js == *!(.js|.css) ]] && echo yup
yup The reason is that the Additionally, a negated pattern can match the empty string! So, for example: $ [[ foo. == *.!(js|css) ]] && echo yup
yup The $ [[ foo.min.js == *!(.min).js ]] && echo yup
yup
|
@isaacs, thanks for your explanation :)
Imho not. This doesn't explain the difference between these 2 examples:
It seems to me that minus has some special meaning here. Anyway, I totally agree with deprecating the whole negation "feature" in minimatch. It causes more problems than benefit. |
Ah damn, you're right. Thanks @gera2ld :) |
Found the problem. The way that negative lookaheads are being used is not sufficient. If the negated part of the pattern appears at the start of a longer pattern, it's failing because it does match the negative lookahead. For example, the pattern Annotated:
The mistake here is that the negative lookahead portion needs to cover the entire pattern after the lookahead pattern, not just the bit within it's capture group. That means, effectively, any negative group needs to include the rest of the regexp after that point within the If so, then this is the regexp that it should produce in that case:
That means keeping track of the start and stop of each negative group, and some string slicing for each of them, moving from last to first, before parsing the regular expression. Totally doable, just some new JavaScript to type. |
Can one of you try doing I do still want to deprecate |
I am trying to filter files by extnames:
Are the results expected?
The text was updated successfully, but these errors were encountered: