Skip to content

Add --no-matches-message flag for empty search results#2015

Open
leno23 wants to merge 1 commit into
sharkdp:masterfrom
leno23:feat/no-matches-message-1819
Open

Add --no-matches-message flag for empty search results#2015
leno23 wants to merge 1 commit into
sharkdp:masterfrom
leno23:feat/no-matches-message-1819

Conversation

@leno23
Copy link
Copy Markdown

@leno23 leno23 commented May 25, 2026

Summary

  • Adds a new --no-matches-message flag that prints a status message to stderr when a search yields no results
  • Message format: [fd]: No matches found for pattern: '{pattern}' (or [fd]: No matches found when no pattern is given)
  • Respects -q / --quiet (no message printed)
  • Default behavior remains unchanged (silent when no matches)

Fixes #1819

Test plan

  • cargo test test_no_matches_message — verifies message is printed with the flag
  • cargo test test_no_matches_message_respects_quiet — verifies quiet mode suppresses the message
  • cargo test — full test suite passes (139 unit + 109 integration tests)

Print an optional status message to stderr when a search yields no
results. Respects quiet mode and does not affect the default silent
behavior.

Fixes sharkdp#1819
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c2a98993c6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/walk.rs

if self.num_results == 0
&& self.config.no_matches_message
&& self.config.is_printing()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove printing-mode gate for no-match status

--no-matches-message is described as a search-level status flag, but this condition requires self.config.is_printing(), which is false whenever --exec/--exec-batch is used. That makes the new flag silently ineffective in command-execution workflows (e.g., fd --no-matches-message -x ... PATTERN with zero matches), even though those workflows still perform a search and can end with no results. This should either be emitted regardless of print mode (except quiet) or explicitly documented as unsupported for exec modes.

Useful? React with 👍 / 👎.

@leno23 leno23 force-pushed the feat/no-matches-message-1819 branch from c2a9899 to 2778315 Compare May 26, 2026 04:40
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.

No File Found

1 participant