Skip to content

-P accepts multiple patterns where GNU allows only one #34

Closed

Description

@sylvestre

GNU grep's PCRE backend (-P) supports only a single pattern; supplying more than one — via multiple -e, or a single pattern that contains a newline — is rejected with the -P option only supports a single pattern and exit 2. uu_grep accepts multiple patterns under -P and runs the search.

Found by the differential fuzzer (fuzz_grep).

Rust (incorrect)

$ printf 'abc\n' | ./target/release/grep -P -e a -e b
abc
# Exit code: 0

GNU (correct)

$ printf 'abc\n' | LC_ALL=C /usr/bin/grep -P -e a -e b
# Output (stderr): grep: the -P option only supports a single pattern
# Exit code: 2

With -E/-G/-F, multiple -e patterns are accepted by both — the restriction is specific to -P.

Activity

  1. added a commit that references this issue on Jun 5, 2026
    e3d80f5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions