Skip to content

Fix #1873: Show path separator error for all patterns, not just existing directories#1892

Closed
cobyfrombrooklyn-bot wants to merge 1 commit intosharkdp:masterfrom
cobyfrombrooklyn-bot:fix-issue-1873
Closed

Fix #1873: Show path separator error for all patterns, not just existing directories#1892
cobyfrombrooklyn-bot wants to merge 1 commit intosharkdp:masterfrom
cobyfrombrooklyn-bot:fix-issue-1873

Conversation

@cobyfrombrooklyn-bot
Copy link
Copy Markdown

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, which is confusing.

Now the error is always shown when the pattern contains a path separator (and --full-path is 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: Verifies fd foo/bar produces the path separator error (previously silently returned nothing)
  • test_path_separator_in_pattern_existing_directory: Verifies fd one/two still produces the error for existing directories

First 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

…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
@tmccombs
Copy link
Copy Markdown
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.

@tmccombs tmccombs closed this Feb 25, 2026
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.

[BUG] The 'pattern contains path separator' error is only shown when pattern is an existing directory

2 participants