ripgrep icon indicating copy to clipboard operation
ripgrep copied to clipboard

[globset] Make `liberal_separator` the default

Open piegamesde opened this issue 4 years ago • 3 comments

https://docs.rs/globset/0.4.8/globset/struct.GlobBuilder.html#method.literal_separator

I'd like to know why this is not on by default. Setting it would match the default behavior of many software and is also what one might expect. Think of it like this: if a * matches a / and thus multiple hierarchy levels, what is even the point of having ** at all?

piegamesde avatar Nov 12 '21 12:11 piegamesde

I'd like to know why this is not on by default.

The answer is likely unsatisfying: I likely set is as the default to match what the glob crate does, and I believe the glob crate did it that way to match the behavior of fnmatch. For example:

>>> import fnmatch
>>> fnmatch.fnmatch('a/b/c', 'a*c')
True

In the C API of fnmatch, you can pass FNM_PATHNAME to disable this behavior. But the point is that * matching / is the default there.

I probably agree with you that this shouldn't be the default, but it would warrant careful consideration. And this is unlikely to happen any time soon.

BurntSushi avatar Nov 12 '21 12:11 BurntSushi

Thank you for the answer, this is what I feared. The frustrating thing is that fnmatch deviates from glob(7) in that regard, which I would consider as normative.

piegamesde avatar Nov 12 '21 14:11 piegamesde

Note that it is a non-goal to follow glob(7) or anything else that's POSIX, simply because it is POSIX. "Careful consideration" here means looking at globbing implementations in active use. I suspect * not matching / is still indeed in broader use, so I ultimately likely agree with you here. But I just want to be clear that this doesn't mean I accept POSIX rules for globbing wholesale. :)

BurntSushi avatar Nov 12 '21 14:11 BurntSushi