-
Notifications
You must be signed in to change notification settings - Fork 60
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
Glob: Double asterisk is not matching zero directories #185
Comments
@sliquister do you agree that this is a bug? |
@rgrinberg did you actually mean to ask me? I don't know how globs are documented right now, but both git and hg would interpret |
I wrongly recalled that it was you who contributed many improvements to the glob api. It was actually another JaneStreet employee. In any case, I assume you are still using @eWert-Online since we all seem agree with your assessment, would you like to contribute a fix? |
My OCaml isn't that good, but I can at least try 🙂 |
I looked into this, but I think solving this is currently a bit too much for me 😄 I think the problem is, that the parser currently sees the I did write some tests, which test all of the above mentioned. assert (re_match (glob ~anchored "foo/**/bar/**/baz") "foo/bar/baz");
assert (re_match (glob ~anchored "foo/**/bar/**/baz") "foo/bar/x/y/z/baz");
assert (re_match (glob ~anchored "foo/**/bar/**/baz") "foo/x/y/z/bar/baz");
assert (re_match (glob ~anchored "foo/**/bar/**/baz") "foo/bar/x/bar/x/baz");
assert (re_mismatch (glob ~anchored "foo/**/bar/**/baz") "foo/bar/../x/baz");
assert (re_mismatch (glob ~anchored "foo/**/bar/**/baz") "foo/bar/./x/baz"); |
CHANGES: * Add the `[:alpha:]` character class in `Re.Perl` (ocaml/ocaml-re#169) * Double asterisk (`**`) in `Re.Glob` (ocaml/ocaml-re#172) Like `*` but also match `/` characters when `pathname` is set. * Double asterisk should match 0 or more directories unless in trailing position. (ocaml/ocaml-re#192, fixes ocaml/ocaml-re#185)
Using the latest (unreleased) version with #172 already merged, I would expect
**
to match zero or more directories.Given the following two paths
/project/path/test/lib/test.ml
/project/path/test/lib/deep/test2.ml
with the pattern
test/lib/**/*.ml
, I would expect both to be true.Right now however, only the second (deep) one matches.
Doing the same without the
lib
like thistest/**/*.ml
returns both paths as true.This leads me to the conclusion, that
**
right now means one or more directories.(Related to #171)
The text was updated successfully, but these errors were encountered: