Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 28 Apr 2016 21:05:38 -0400
From:      anonymous <johnandsara2@cox.net>
To:        bugzilla-noreply@freebsd.org
Cc:        freebsd-bugs@FreeBSD.org
Subject:   Re: [Bug 209116] bsdgrep -Fxf failing if earlier non-match is a sub-prefix of the actual match
Message-ID:  <5722B362.4070905@cox.net>
In-Reply-To: <bug-209116-8@https.bugs.freebsd.org/bugzilla/>
References:  <bug-209116-8@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
bugzilla-noreply@freebsd.org 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: 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.
> 

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?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5722B362.4070905>