From owner-freebsd-bugs@freebsd.org Fri Apr 29 01:46:20 2016 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id EC0E2B20692 for ; Fri, 29 Apr 2016 01:46:20 +0000 (UTC) (envelope-from johnandsara2@cox.net) Received: from eastrmfepo202.cox.net (eastrmfepo202.cox.net [68.230.241.217]) by mx1.freebsd.org (Postfix) with ESMTP id A06871848 for ; Fri, 29 Apr 2016 01:46:20 +0000 (UTC) (envelope-from johnandsara2@cox.net) Received: from eastrmimpo306.cox.net ([68.230.241.238]) by eastrmfepo202.cox.net (InterMail vM.8.01.05.15 201-2260-151-145-20131218) with ESMTP id <20160429014614.EGUN21150.eastrmfepo202.cox.net@eastrmimpo306.cox.net> for ; Thu, 28 Apr 2016 21:46:14 -0400 Received: from [192.168.3.15] ([72.219.207.23]) by eastrmimpo306.cox.net with cox id o1mD1s0080WpXgw011mEus; Thu, 28 Apr 2016 21:46:14 -0400 X-CT-Class: Clean X-CT-Score: 0.00 X-CT-RefID: str=0001.0A020202.5722BCE6.013E, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CT-Spam: 0 X-Authority-Analysis: v=2.1 cv=HduaT008 c=1 sm=1 tr=0 a=mYpcIwsqoufCTD7dyaqayA==:117 a=mYpcIwsqoufCTD7dyaqayA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=8nJEP1OIZ-IA:10 a=6I5d2MoRAAAA:8 a=pctL93jIT1zxRYExaS4A:9 a=wPNLvfGTeEIA:10 X-CM-Score: 0.00 Authentication-Results: cox.net; none Message-ID: <5722B362.4070905@cox.net> Date: Thu, 28 Apr 2016 21:05:38 -0400 From: anonymous User-Agent: Thunderbird 2.0.0.24 (X11/20100228) MIME-Version: 1.0 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 References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Apr 2016 01:46:21 -0000 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?