Show path-separator error for all patterns containing '/', not just directories#1887
Closed
danielalanbates wants to merge 2 commits intosharkdp:masterfrom
Closed
Show path-separator error for all patterns containing '/', not just directories#1887danielalanbates wants to merge 2 commits intosharkdp:masterfrom
danielalanbates wants to merge 2 commits intosharkdp:masterfrom
Conversation
…irectories Previously, the error about a search pattern containing a path separator was only shown when the pattern also happened to be an existing directory. Patterns like 'foo/bar' that aren't directories would silently return no results without any hint about the issue. Now the error is always shown when the pattern contains a path separator (and --full-path is not used). The "search inside directory" suggestion is only shown when the pattern is an actual directory, while the "use --full-path" suggestion is always shown. Closes sharkdp#1873 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
On Windows, std::path::MAIN_SEPARATOR is '\' which conflicts with regex escape sequences (e.g. \Ac, \d, \w). Retain the is_dir() guard on Windows to avoid false positives, while keeping the broader check on Unix where '/' is unambiguous. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
|
There is already a PR for this. This also doesn't update the changelog, or add any tests. And it doesn't address the issue that on windows the path separator is also the regex escape character. |
Author
|
Thanks for pointing out the existing PR. Apologies for the duplicate! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The "pattern contains path separator" error was only shown when the pattern also happened to be an existing directory (e.g.,
fd Programs/wherePrograms/exists). Patterns likefd foo/barthat aren't directories silently returned no results with no diagnostic.Now the error is always shown when the pattern contains a path separator and
--full-pathis not used. The "search inside directory" suggestion is conditionally shown only when the pattern is an actual directory.Example
Before (pattern is not a directory — no error, silent empty results):
After:
Closes #1873
🤖 Generated with Claude Code