From owner-freebsd-bugs@FreeBSD.ORG Wed Apr 11 19:30:16 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 33A89106566C for ; Wed, 11 Apr 2012 19:30:16 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 1E8DF8FC0A for ; Wed, 11 Apr 2012 19:30:16 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q3BJUFMi081181 for ; Wed, 11 Apr 2012 19:30:15 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q3BJUFgv081178; Wed, 11 Apr 2012 19:30:15 GMT (envelope-from gnats) Date: Wed, 11 Apr 2012 19:30:15 GMT Message-Id: <201204111930.q3BJUFgv081178@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Jim Pryor Cc: Subject: Re: bin/166842: bsdgrep(1) inconsistently handles ^ in non-anchoring positions X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Jim Pryor List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Apr 2012 19:30:16 -0000 The following reply was made to PR bin/166842; it has been noted by GNATS. From: Jim Pryor To: bug-followup@FreeBSD.org Cc: Subject: Re: bin/166842: bsdgrep(1) inconsistently handles ^ in non-anchoring positions Date: Wed, 11 Apr 2012 15:21:01 -0400 I've noticed some more issues with the same version of grep. I don't know whether they're related, but I'll append them here for now. $ printf abc | grep -o '^[a-c]' should just print 'a', but instead gives three hits, against each letter of the incoming text. The same issue occurs when handling multiline buffers: $ printf 'abc\ndef' | grep -o --null '^[a-f]' incorrectly matches 6 times. $ printf 'abc\ndef' | grep -o --null '[a-f]$' correctly only matches 'c' and 'f'. $ printf 'abc\ndef' | grep -o --null '\`[a-f]' has the same issue as ^, whereas: $ printf 'abc\ndef' | grep -o --null '[a-f]\'\' matches 'c' and 'f'. To fix \` in a way that matches the behavior of \', it should only match the 'a' and 'd'. In fact, though, both of these should only match against a single character: 'a' for \` and 'f' for \'. That's the specified behavior of these Gnu extensions, and how they behave in the Gnu grep and BusyBox grep implementations I'm testing against. If that behavior isn't going to be provided, then wouldn't it'd be better for these extensions not even pretend to be present? And so, just match against a literal ` or '? -- dubiousjim@gmail.com