Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Nov 2022 19:48:48 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 267749] Running "grep -Fivx -f known.words new.words" gives wrong result
Message-ID:  <bug-267749-227@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D267749

            Bug ID: 267749
           Summary: Running "grep -Fivx -f known.words new.words" gives
                    wrong result
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: jonathan.leffler@gmail.com

Created attachment 238058
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D238058&action=
=3Dedit
List of known words in the repro

The command "grep -Fivx -f known.words new.words" is meant to compare a
list of putatively new words against a list of known words, reporting
only those new words not present amongst the known words.  The context
is a script for helping with the New York Times "Spelling Bee" puzzle,
but that doesn't matter much.

Testing "grep (BSD grep) 2.5.1-FreeBSD" as found on macOS Big Sur 11.7.1
against "grep (GNU grep) 2.27", I get different results for the following
files:

New Words:
    decedent
    deceived
    decident
    detected
    dietetic

Known Words:
    Civic
    Decedent
    Deceit
    Deceive
    Deceived
    Decent
    Decide
    Decided
    Deiced
    Detect
    Detected
    Detective
    Device
    Dice

There are no blanks in the files; the only white space is the newlines.
There are no blank lines in the files.

GNU grep produces the (correct) list:
    decident
    dietetic

BSD grep produces the (incorrect) list:
    deceived
    decident
    detected
    dietetic

Both "deceived" and "detected" are in the list of known words and
neither should be reported.

I believe this is a bug in BSD grep.  My short-term workaround is to use
GNU grep, but I'd rather it wasn't necessary.  I'm not clear whether this
should be reported to Apple or FreeBSD (or both).

(I think I ran into 253209 "grep -v -f some-empty-file -- does the wrong th=
ing"
previously, but I worked around that, too.  It isn't directly relevant to t=
his
bug, though; neither file is empty in this bug.)

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-267749-227>