-
-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Incorrect matching for parenthesis #7
Comments
/cc @jonschlinkert can we fix it too? It is blocker (#8 too) for updating |
Sorry for the late reply! @mrmlnc that isn't a valid extglob. Exglobs must be preceeded by one of these characters: You can do the following to achieve what you want: const picomatch = require('picomatch');
const correct = picomatch.makeRe('\\(special\\).txt'); // parentheses are not valid extglobs
console.log(correct);
//=> /^(?:\(special\)\.txt)$/ I think minimatch just escapes everything it doesn't recognize, which is a lot. But minimatch also is just plain wrong a lot of the time, I don't recommend using it as the "correct source". For example: console.log(minimatch.makeRe('mu!(*(c))?.pa!(*(z))?'));
//=> /^(?:(?=.)mu(?:(?!(?:(?:c)*)[^\/]\.pa(?:(?!(?:(?:z)*)[^\/])[^\/]*?)[^\/])[^\/]*?)[^\/]\.pa(?:(?!(?:(?:z)*)[^\/])[^\/]*?)[^\/])$/ Notice the double generation of the pattern? |
@mrmlnc @evilebottnawi ping. Seems like this should be closed, correct? |
IMHO, the *match packages should work like Bash wildcards on all systems. Because we don't have any standard here. The following behavior applies to PowerShell on Windows.
This is correct behaviour for Bash wildcards:
But… but after the
|
@mrmlnc it seems like picomatch is doing what Bash does, and it sounds like you're saying that you agree that following Bash is what we should do. But then you say:
Minimatch doesn't handle non-extglob parentheses at all. It just escapes them.
It is already mentioned here: https://github.com/micromatch/picomatch#matching-special-characters-as-literals
I'm open to adding support for a |
My apologies for the delay. I think we can make a function that will escape all special characters. Just a function that escapes all special characters in the pattern. Something similar: https://facelessuser.github.io/wcmatch/glob/#globescape Also it can also be useful for the I can do a PR if you don't mind. |
If you knew that all special characters should be escaped, why would you pass the pattern to picomatch at all?
Since you'd want to escape the file path before joining it to the glob, I can see how this would make more sense in fast-glob. |
Source
(
and)
on windows and linux mrmlnc/fast-glob#160Actual behavior
Now parenthesis are not escaped.
Expected behavior
Brackets are escaped or
noextglob
can affect on results. Works fine withminimatch
andfnmatch
(Python).Code sample
The text was updated successfully, but these errors were encountered: