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
Bug with partial wildcards #15
Comments
Looks like it's specific to the globstar occurring right after the partial (tailing) wildard - the
|
Been digging into this. Focusing on this line atm https://github.com/jonschlinkert/micromatch/blob/c007899ae1e288310cc0c43d5d57faf6d7ec671a/lib/expand.js#L138 Appears to be where the globstar handling fails, probably because of the |
Ok it's actually the Replacing them with |
The fix described in the last comment did not fully resolve the issue. There seems to be a secondary problem with partial wildcard matches after a globstar as well.
|
sorry I've been offline all day. just reading over this now |
Was just beginning to prepare a branch and PR |
did you figure out which regex was causing it? |
crazy that this pattern wouldn't be anywhere in the unit tests... |
I have figured out half of the issue so far - with the |
Ok, I can get it the rest of the way. Do you want to do the pr still? |
Sorry you had to deal with this. |
Yeah I'll get the PR started in a minute, but on a branch here so you'll be able to keep pushing commits to it and finish up.
No worries. It was an opportunity to get acquainted with how this thing works |
ah, wait, this is the one that's causing the issue, right?
If so, I can fix that, but it was intentional, since that's how the specification is written, but it's not how minimatch works. I like how minimatch works for this - so we can change it |
great, thanks! |
I'm looking for that spec, it was either wildmatch (used by git) or bash. no matter though since we're changing it |
That's the part I hadn't solved yet. This is a separate problem as well (which I have solved)
|
ok, great. |
@es128 would you mind pushing up some failing unit tests that describe all the failing patterns? Maybe just create a section right here and name it something like |
ha, well you might have already done it. and that's a better place too probably |
Yeah I tried to isolate them to expose the observed issues in the simplest possible form (and potential related ones). But I was mainly focusing on the use case that I started with - I suspect there are more holes that can be poked. Would take a close look at any regex that uses |
looks like they're all they same issue.
If it makes sense to change all boundaries to use slashes instead of word characters. I'll try to get this one fixed then we can go from there and decide where else we want to depart from spec |
btw, one thing that might not be immediately obvious in |
That did confuse me briefly when I was monitoring the value of |
quick glance, there are only four places using
but the other we might be able to get rid of |
did you notice the |
it might not be documented... |
Sorry AFK at this point. But no, didn't notice it
|
no prob. I'm on it |
no you're right. that would be a match. |
oh interesting, turns out github comments drops a * when there are two in a quote |
yeah I just saw that too lol. I had to edit and add backticks |
Why are you getting different results?
|
not with micromatch. minimatch produces a different answer between the two methods |
you show |
oh, wait. I think I missed the point. yeah one sec |
wanted to double check. yes you're correct. I just didn't update the result in the comments before I pasted. seems important to do lol |
ok, corrected |
I'm thinking we're in good shape for now. so far, everything seems to be consistent with the spec. |
ok yeah... we have beat this to death for every example that's been discussed, micromatch's current behavior is correct, and the tests are appropriate for keeping it that way @tunnckoCore I hope satisfactory proof has been provided for you. If not, I'm sorry. But I, for one, am done here. |
haha, okey thanks guys. I dont like the results, but okey. |
For reference, if you want a pattern that says one or more subdirs (instead of 0 or more), use |
but .. doh. I cant understand why this is true (as shown in examples) console.log(micromatch.isMatch('z.js', '**/z*.js'));
//=> true and this is false console.log(micromatch.isMatch('a/z.js', 'a/z*.js'));
//=> false |
ah you're right on this one, you've spotted a bug. Second example should be |
doh, noooo, opposite :D |
first is absolutely wrong for me. and think it, if it have ability to talk it would say "a want dir and something starting with |
nope, sorry - that's just is not how it's supposed to be. If you want that it would be |
what? |
to express that as a glob: or if you meant a javascript file one star instead of two. |
so one star means one or more? lol |
one star means zero or more characters. In the context of being the only thing between path separators, it means exactly one dir with any name. |
var micromatch = require('micromatch');
var paths = [
'd.js',
'e.php',
'z.js',
'a/b.cs',
'a/k.php',
'a/z.js',
'a/b/h.js',
'a/b/c/z.js'
];
console.log(micromatch.isMatch('z.js', '**/z*.js'));
//=> true
console.log(micromatch.isMatch('a/z.js', 'a/z*.js'));
//=> false
console.log(micromatch(paths, '**/z*.js'));
//=> [ 'z.js', 'a/z.js', 'a/b/c/z.js' ]
console.log(micromatch(paths, '*/z*.js'));
//=> []
console.log(micromatch(paths, '*/*.js'));
//=> [ 'a/z.js' ]
console.log(micromatch(paths, '**/*.js'));
//=> [ 'd.js', 'z.js', 'a/z.js', 'a/b/h.js', 'a/b/c/z.js' ]
console.log(micromatch(paths, '*z*.js'));
//=> [ 'z.js' ]
console.log(micromatch(paths, '**z*.js'));
//=> [ 'z.js', 'a/z.js', 'a/b/c/z.js' ] |
You've identified one bug and represented it twice in these examples: console.log(micromatch.isMatch('a/z.js', 'a/z*.js'));
//=> should be true
console.log(micromatch(paths, '*/z*.js'));
//=> should be [ 'a/z.js' ] And then potentially one more with that last example, although it's a more academic case that wouldn't be found among anyone's legitimate use cases. |
and multimatch // multimatch
console.log(multimatch(paths, '**/z*.js'));
//=> [ 'z.js', 'a/z.js', 'a/b/c/z.js' ]
console.log(multimatch(paths, '*/z*.js'));
//=> [ 'a/z.js' ]
console.log(multimatch(paths, '*/*.js'));
//=> [ 'a/z.js' ]
console.log(multimatch(paths, '**/*.js'));
//=> [ 'd.js', 'z.js', 'a/z.js', 'a/b/h.js', 'a/b/c/z.js' ]
console.log(multimatch(paths, '*z*.js'));
//=> [ 'z.js' ]
console.log(multimatch(paths, '**z*.js'));
//=> [ 'z.js' ] |
@tunnckoCore can I just ask why you're doing this? you said you don't use this, but you're trying your best to find bugs - which IMO is fine b/c it helps us, but I don't get the impression you're pointing out flaws to try to be helpful here. |
b/c I will use it, but it looks wrong to me. nevermind |
Yeah we're just going to have to move on. @tunnckoCore you've made your point that you disagree with how globstar is intended to work as agreed upon in every spec and implementation we can find, but that's how it is (and it isn't an arbitrary decision by @jonschlinkert nor I that you can talk us out of). I'd suggest you either adjust your understanding or just refrain from using globstar functionality in your glob patterns. Your (constructive) feedback continues to be welcome (at least as far as I'm concerned), and thank you for helping to uncover two new bugs. |
Realized this is the cause of a few newly failing tests in chokidar
The text was updated successfully, but these errors were encountered: