Skip to content

fix: show path-separator error regardless of directory existence#1978

Closed
avasis-ai wants to merge 1 commit intosharkdp:masterfrom
avasis-ai:fix-path-separator-error-consistency
Closed

fix: show path-separator error regardless of directory existence#1978
avasis-ai wants to merge 1 commit intosharkdp:masterfrom
avasis-ai:fix-path-separator-error-consistency

Conversation

@avasis-ai
Copy link
Copy Markdown

Summary

The 'pattern contains a path separator' error was only shown when the pattern happened to be an existing directory. This made the behavior inconsistent — fd / showed the error (because / is a directory), but fd nonexistent/path silently returned no results.

This PR removes the Path::new(&opts.pattern).is_dir() check so the error is shown consistently for any pattern containing a path separator character.

Note: On Windows, \ is both the path separator and a regex escape character, so this fix may produce false positives for patterns like \d. A follow-up could be to only apply this check when the pattern is not a valid regex, but that's a larger change.

Closes #1873

The error about a pattern containing a path separator was only shown
when the pattern happened to be an existing directory. Now it shows
consistently for any pattern containing a path separator character.
@tmccombs
Copy link
Copy Markdown
Collaborator

Closing in favor of #1975

@tmccombs tmccombs closed this Apr 20, 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

3 participants