Skip to content

Show path-separator error for all patterns containing '/', not just directories#1887

Closed
danielalanbates wants to merge 2 commits intosharkdp:masterfrom
danielalanbates:fix/path-separator-error-consistency
Closed

Show path-separator error for all patterns containing '/', not just directories#1887
danielalanbates wants to merge 2 commits intosharkdp:masterfrom
danielalanbates:fix/path-separator-error-consistency

Conversation

@danielalanbates
Copy link

Summary

The "pattern contains path separator" error was only shown when the pattern also happened to be an existing directory (e.g., fd Programs/ where Programs/ exists). Patterns like fd foo/bar that 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-path is 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):

$ fd foo/bar
$

After:

$ fd foo/bar
[fd error]: The search pattern 'foo/bar' contains a path-separation character ('/') and will not lead to any search results.

If you want your pattern to match the full file path, use:

  fd --full-path 'foo/bar'

Closes #1873

🤖 Generated with Claude Code

Your Name and others added 2 commits February 19, 2026 10:10
…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>
@tmccombs
Copy link
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.

@tmccombs tmccombs closed this Feb 20, 2026
@danielalanbates
Copy link
Author

Thanks for pointing out the existing PR. Apologies for the duplicate!

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