Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Apr 2016 01:25:06 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 209116] bsdgrep -Fxf failing if earlier non-match is a sub-prefix of the actual match
Message-ID:  <bug-209116-8@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help

https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209116

            Bug ID: 209116
           Summary: bsdgrep -Fxf failing if earlier non-match is a
                    sub-prefix of the actual match
           Product: Base System
           Version: 9.1-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: freebsd-bugs@FreeBSD.org
          Reporter: shane@itlab.co.nz

I have a script that generates a list of pending build targets and a list of
targets this machine can build, and generates the intersection list using grep
-Fxf. On our Mac it was behaving strangely and I've tracked and reduced it to
the following snippets.

Although found on OSX, I've reproduced this bug using the bsdgrep command in
FreeBSD 9.0-RELEASE (bsdgrep -V -> "bsdgrep (BSD grep) 2.5.1-FreeBSD"). The
grep on OSX is bsdgrep, while on my BSD it is GNU grep.


# -F=fixed strings, -x=match whole lines, -f=read patterns from file
printf "linux\nbsd\nmacosx64\n" | bsdgrep -Fxf <(printf "macosx\nmacosx64\n")
gives no result, but the following work fine.

# swap pattern order
printf "linux\nbsd\nmacosx64\n" | bsdgrep -Fxf <(printf "macosx64\nmacosx\n")
# search for prefix substring
printf "linux\nbsd\nmacosx\n" | bsdgrep -Fxf <(printf "macosx\nmacosx64\n")
# in either pattern order
printf "linux\nbsd\nmacosx\n" | bsdgrep -Fxf <(printf "macosx64\nmacosx\n")

It seems to fail to match a line that contains an earlier pattern match as a
prefix.

I will simply avoid this problem by using comm instead, but I'll hang around
for a while to answer any questions that come up.

-- 
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-209116-8>