Skip to content

Show path separator error regardless of directory existence#1

Open
bejaratommy wants to merge 1 commit intomasterfrom
fix/path-separator-error-consistency
Open

Show path separator error regardless of directory existence#1
bejaratommy wants to merge 1 commit intomasterfrom
fix/path-separator-error-consistency

Conversation

@bejaratommy
Copy link
Copy Markdown
Owner

Summary

Previously, fd only warned about patterns containing path separators when the pattern also happened to be an existing directory. This led to inconsistent behavior:

  • fd / → error (because / is a directory)
  • fd nonexistent/path → silent, no results

Since filenames cannot contain path separators, a pattern with a path separator (without --full-path) will never match anything, so the warning should always be shown.

Changes

  • Removed the Path::new(pattern).is_dir() guard from the path separator check
  • When the pattern IS an existing directory, the error still includes the suggestion to search inside it (fd . 'dir')
  • When the pattern is NOT an existing directory, the error only suggests --full-path
  • Added integration tests covering both cases plus the --full-path bypass
  • Updated CHANGELOG.md

Fixes sharkdp#1873

Previously, `fd` only warned about patterns containing path separators
when the pattern also happened to be an existing directory. This was
inconsistent: patterns with path separators will never match any
filenames (since filenames cannot contain path separators), so the
warning is helpful regardless.

Now the error is always shown when a pattern contains a path separator
and `--full-path` is not set. When the pattern is an existing directory,
the suggestion to search inside it is still included.

Fixes sharkdp#1873
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

1 participant