HomeFreeBSD

bsdgrep: Fix --include/--exclude ordering issues

Description

bsdgrep: Fix --include/--exclude ordering issues

Prior to r332851:

  • --exclude always win out over --include
  • --exclude-dir always wins out over --include-dir

r332851 broke that behavior, resulting in:

  • First of --exclude, --include wins
  • First of --exclude-dir, --include-dir wins

As it turns out, both behaviors are wrong by modern grep standards- the
latest rule wins. e.g.:

grep --exclude foo --include foo 'thing' foo
foo is included

grep --include foo --exclude foo 'thing' foo
foo is excluded

As tested with GNU grep 3.1.

This commit makes bsdgrep follow this behavior.

Reported by: se

Details

Provenance
kevansAuthored on
Parents
rS332855: MFC r332414:
Branches
Unknown
Tags
Unknown