Skip to content

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

Closed

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

Activity

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