Skip to content

Commit 99d0194

Browse files
committed
Fix: Show path separator error regardless of directory existence
Fixes #1873 The error message about patterns containing path separators was only shown when the pattern was also an existing directory. This change makes the error consistent by showing it whenever a pattern contains a path separator (and --full-path is not used), regardless of whether the pattern is an existing directory. This ensures users get helpful feedback even when they accidentally use a path separator in a pattern that doesn't exist as a directory.
1 parent bf81fb9 commit 99d0194

1 file changed

Lines changed: 1 addition & 4 deletions

File tree

src/main.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,7 @@ fn set_working_dir(opts: &Opts) -> Result<()> {
147147

148148
/// Detect if the user accidentally supplied a path instead of a search pattern
149149
fn ensure_search_pattern_is_not_a_path(opts: &Opts) -> Result<()> {
150-
if !opts.full_path
151-
&& opts.pattern.contains(std::path::MAIN_SEPARATOR)
152-
&& Path::new(&opts.pattern).is_dir()
153-
{
150+
if !opts.full_path && opts.pattern.contains(std::path::MAIN_SEPARATOR) {
154151
Err(anyhow!(
155152
"The search pattern '{pattern}' contains a path-separation character ('{sep}') \
156153
and will not lead to any search results.\n\n\

0 commit comments

Comments
 (0)