Fix #1873: Show path separator error for all patterns, not just existing directories#1892
Closed
cobyfrombrooklyn-bot wants to merge 1 commit intosharkdp:masterfrom
Closed
Fix #1873: Show path separator error for all patterns, not just existing directories#1892cobyfrombrooklyn-bot wants to merge 1 commit intosharkdp:masterfrom
cobyfrombrooklyn-bot wants to merge 1 commit intosharkdp:masterfrom
Conversation
…ries Previously, the error about a search pattern containing a path separator was only shown when the pattern happened to be an existing directory. Patterns like 'foo/bar' that contain '/' but are not existing directories would silently produce no results. Now the error is shown whenever the pattern contains a path separator (and --full-path is not used). The directory-specific hint about using 'fd . <dir>' is only shown when the pattern is actually a directory. Fixes sharkdp#1873
Collaborator
|
There is already a PR for this. I also don't see how thos fixes the problem, it is just moving the condition around. It also looks to me like it was AI generated. |
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.
Previously, the error about a search pattern containing a path separator was only shown when the pattern happened to be an existing directory. Patterns like
foo/barthat contain/but are not existing directories would silently produce no results, which is confusing.Now the error is always shown when the pattern contains a path separator (and
--full-pathis not used). The directory-specific hint ("If you want to search for all files inside the directory...") is conditionally shown only when the pattern is actually a directory.Changes
src/main.rs: Removed&& Path::new(&opts.pattern).is_dir()condition from the path separator check. The error message is now built dynamically: the directory hint is only included when the pattern is an existing directory.Test
Added two integration tests in
tests/tests.rs:test_path_separator_in_pattern_non_directory: Verifiesfd foo/barproduces the path separator error (previously silently returned nothing)test_path_separator_in_pattern_existing_directory: Verifiesfd one/twostill produces the error for existing directoriesFirst test fails without the fix (no error produced), passes with it. Full test suite: 105 passed, 0 failed.
Tested locally on macOS ARM (Apple Silicon).
Fixes #1873