BurntSushi / BurntSushi/ripgrep
[globset] supporting paths with Windows separators
- Dominant language
- Rust
- Stars
- 68.3k
- Forks
- 2.8k
- PR merge metrics
- No merged PRs in 30d
Description
#### Describe your feature request
Hi Andrew! Thanks for all your wonderful crates.
I noticed that `globset` currently seems to have certain Unix assumptions baked in, such as `literal_separator` only excluding `/` and not `\`.
I'm wondering if it would be possible to run it in a mode where it supports Windows paths, without having the path converted from `\` to `/`. The general approach I'm thinking is:
* globs are still provided in Unix format with `/` path separators.
* `literal_separator` is turned on.
* a new config `match_backslash_separator` is provided (people can turn it on on `#[cfg(windows)]`, or maybe it could take an enum with values like `Never`, `OnWindows`, `Always`).
* internally, `globset` converts `/` in the glob to `[/\\]` in the regex, and makes it so that `literal_separator` doesn't match either `/` or `\`.
I might have missed something but I believe this should work. (It could also run in a "canonical Windows path" mode, where `/` in the glob *only* matches `\` in the string, but I'm not sure if there's a good use case for that.)
Contributor guide
Research direction
Start by reading globset's handling of literal_separator and its glob-to-regex conversion. Evaluate the proposed match_backslash_separator configuration and verify that slash separators and literal matching behave correctly for Windows paths without converting the input path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli, search
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100