Skip to content

-l and -L are not mutually exclusive last-wins like GNU #26

@sylvestre

Description

@sylvestre

-l (--files-with-matches) and -L (--files-without-match) are opposites. GNU treats them as mutually exclusive with last-one-wins semantics. uu_grep keeps both flags independently active and always lets -l win, so -l -L (with -l first) diverges.

Found by the differential fuzzer (fuzz_grep).

Rust (incorrect)

$ printf 'match5here\n' > /tmp/p.txt
$ ./target/release/grep -e 5 -l -L /tmp/p.txt
/tmp/p.txt
# Exit code: 0

GNU (correct)

$ printf 'match5here\n' > /tmp/p.txt
$ LC_ALL=C /usr/bin/grep -e 5 -l -L /tmp/p.txt
# Output: (none — last flag is -L, and the file *does* match, so it is not listed)
# Exit code: 0

With the order reversed (-L -l, last flag -l) both print the filename, confirming GNU's last-wins rule. uu_grep prints the filename in both orders.

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