Skip to content

fix: normalize path separators for --full-path glob matches on Windows - #2089

Open
petrroll wants to merge 1 commit into
sharkdp:masterfrom
petrroll:fix/windows-full-path-globs
Open

fix: normalize path separators for --full-path glob matches on Windows#2089
petrroll wants to merge 1 commit into
sharkdp:masterfrom
petrroll:fix/windows-full-path-globs

Conversation

@petrroll

@petrroll petrroll commented Aug 4, 2026

Copy link
Copy Markdown

In glob mode the search regex is taken straight out of globset, which always emits / as the separator, both for literals (\ in a pattern is parsed as Token::Literal('/') on Windows) and for the generated [^/], (?:/?|.*/), /.* constructs. globset's own matcher completes that contract by normalizing the candidate in Candidate::new, but fd uses the extracted regex directly, so with --full-path the pattern was /-separated while the candidate was a native Windows path and nothing ever matched.

Normalize the candidate the same way globset does, but only when it can matter: --glob together with --full-path. --regex overrides --glob, so native-separator regexes keep seeing unmodified paths.

See #2067.

Alternative to another (also good!) approach of #2074

In glob mode the search regex is taken straight out of globset, which
always emits `/` as the separator, both for literals (`\` in a pattern is
parsed as `Token::Literal('/')` on Windows) and for the generated
`[^/]`, `(?:/?|.*/)`, `/.*` constructs. globset's own matcher completes
that contract by normalizing the candidate in `Candidate::new`, but fd
uses the extracted regex directly, so with --full-path the pattern was
`/`-separated while the candidate was a native Windows path and nothing
ever matched.

Normalize the candidate the same way globset does, but only when it can
matter: --glob together with --full-path. --regex overrides --glob, so
native-separator regexes keep seeing unmodified paths.

See sharkdp#2067.
@petrroll
petrroll force-pushed the fix/windows-full-path-globs branch from 48c2e3c to da014e7 Compare August 4, 2026 22:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant