[email protected] wrote:
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: [email protected]
          Reporter: [email protected]

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.


input file is stdin by pipe: "linux\nbsd\nmacosx\n"

-F  fixed strings "match any of list of strings" ?
    (seems like one should use regex \| for that but ok)

-x  "select input lines wholey matching pattern"
    (you have \n in your pattern, i am unsure if that
     is supposed to be implied and left out or not)

-f FILE
    but you gave no file, instead redirected a second
    stdin - and it is unclear if grep will read both
    and close both redirections - also unclear if your
    shell (tcsh or sh or bash) would also have a standard
    for that)

i think your example is unclear and omitting the arg for -f
tells me you may not have spent enough time reading man pages

am i right?
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to