Skip to content

grep: suppress EOF output in quiet mode - #41

Merged
lhecker merged 1 commit into
uutils:mainfrom
wondr-wclabs:codex/quiet-suppresses-counts
Jun 5, 2026
Merged

lhecker merged 1 commit into
uutils:mainfrom
wondr-wclabs:codex/quiet-suppresses-counts

Conversation

@wondr-wclabs

Copy link
Copy Markdown
Contributor

Fixes #22.

-q already suppresses output on the match path because session_handle_match returns early. The no-match path still reached EOF bookkeeping, so -q -c could print a final count and -q -L could print the filename.

This adds the same quiet-mode suppression at session_finalize, before EOF-only outputs are emitted. That keeps quiet mode responsible for exit status only, regardless of whether the search exits on a match or reaches EOF with no matches.

Covered cases:

  • grep -q -c z with no match: exit 1, no output
  • grep -q -L z with no match: exit 1, no output

Validated with:

  • cargo test quiet_modes -- --nocapture
  • cargo fmt --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test

@codspeed

codspeed Bot commented Jun 5, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 10 untouched benchmarks
⏩ 17 skipped benchmarks1


Comparing wondr-wclabs:codex/quiet-suppresses-counts (364c0ca) with main (f4798cb)

Open in CodSpeed

Footnotes

  1. 17 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Comment thread src/searcher.rs Resolved
@lhecker
lhecker merged commit 55a7b01 into uutils:main Jun 5, 2026
14 checks passed
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.

handles -q -c differently from GNU (prints the count 0 on no match instead of staying silent)

2 participants