BurntSushi / ripgrep

ripgrep recursively searches directories for a regex pattern while respecting your gitignore
The Unlicense
48.18k stars 1.98k forks source link

[globset] Make `liberal_separator` the default #2059

Open piegamesde opened 2 years ago

piegamesde commented 2 years ago

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?

BurntSushi commented 2 years ago

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.

piegamesde commented 2 years ago

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.

BurntSushi commented 2 years ago

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. :)