Skip to content

accepts conflicting matcher flags instead of erroring like GNU (-F/-E/-G/-P combinations) #3

@sylvestre

Description

@sylvestre

When two different matcher-selection flags are given on the same command line
(-F/--fixed-strings, -E/--extended-regexp, -G/--basic-regexp,
-P/--perl-regexp), GNU grep treats it as a usage error and exits with code
2 and the message conflicting matchers specified. uu_grep silently lets the
last flag win and performs the match, exiting 0/1.

Repeating the same matcher flag (e.g. -F -F) is accepted by both and is not
affected.

Rust (incorrect - accepts the conflict)

$ printf 'abc\n' | ./target/release/grep -e . -F -G
abc
# Exit code: 0

GNU (correct)

$ printf 'abc\n' | LC_ALL=C /usr/bin/grep -e . -F -G
grep: conflicting matchers specified
# Exit code: 2

Affected combinations

Every pairing of two different matcher types diverges (Rust accepts, GNU errors
with exit 2):

flags uu_grep GNU
-F -G 0 2
-F -E 0 2
-E -G 0 2
-G -E 0 2
-P -F 1 2
-P -E 0 2
-P -G 0 2
-G -F -E 0 2
-F -F 1 1
-E -E 0 0

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