Skip to content

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

@sylvestre

Description

@sylvestre

-q/--quiet must write nothing to stdout. When -q is combined with -c and the input contains no match, uu_grep still prints the count 0. GNU prints nothing. (When there is a match both stay silent, because -q makes the search exit early before the count is emitted — so the divergence only shows on the no-match path.)

Found by the differential fuzzer (fuzz_grep).

Rust (incorrect)

$ printf 'foo\n' | ./target/release/grep -e 'ZZZ' -q -c
# Output: 0
# Exit code: 1

GNU (correct)

$ printf 'foo\n' | LC_ALL=C /usr/bin/grep -e 'ZZZ' -q -c
# Output: (none)
# Exit code: 1

Controls that agree: -q -c with a match prints nothing in both; -q alone (no -c) prints nothing in both.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions