From owner-freebsd-bugs@FreeBSD.ORG Wed Apr 11 13:50:13 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 0E0E3106566B for ; Wed, 11 Apr 2012 13:50:13 +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 C2C288FC17 for ; Wed, 11 Apr 2012 13:50:12 +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 q3BDoC7X066860 for ; Wed, 11 Apr 2012 13:50:12 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q3BDoC8o066859; Wed, 11 Apr 2012 13:50:12 GMT (envelope-from gnats) Resent-Date: Wed, 11 Apr 2012 13:50:12 GMT Resent-Message-Id: <201204111350.q3BDoC8o066859@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Jim Pryor Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id AE0C2106564A for ; Wed, 11 Apr 2012 13:49:56 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 99C018FC12 for ; Wed, 11 Apr 2012 13:49:56 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q3BDnuJ4085524 for ; Wed, 11 Apr 2012 13:49:56 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.4/8.14.4/Submit) id q3BDnuFU085523; Wed, 11 Apr 2012 13:49:56 GMT (envelope-from nobody) Message-Id: <201204111349.q3BDnuFU085523@red.freebsd.org> Date: Wed, 11 Apr 2012 13:49:56 GMT From: Jim Pryor To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/166842: bsdgrep inconsistently handles ^ in non-anchoring positions X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Apr 2012 13:50:13 -0000 >Number: 166842 >Category: bin >Synopsis: bsdgrep inconsistently handles ^ in non-anchoring positions >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Apr 11 13:50:12 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Jim Pryor >Release: 9.0-PRELEASE >Organization: >Environment: FreeBSD vaio.jimpryor.net 9.0-PRERELEASE FreeBSD 9.0-PRERELEASE #0: Tue Nov 29 02:45:33 EST 2011 root@vaio.jimpryor.net:/usr/obj/usr/src/sys/MINE amd64 >Description: version line: /* $FreeBSD: src/usr.bin/grep/grep.c,v 1.11.2.3 2011/10/20 16:08:11 gabor Exp $ According to the POSIX-2008 standard, "^" and "$" should be ordinary characters in BREs (basic regexs) when they're not in anchoring positions (as contrasted to EREs, where they should always be anchors). Hence: $ printf 'a^b$c' | grep -o 'a^b' should match, and it does when I use Gnu grep (on Linux), and using BusyBox grep (again on Linux, built against uClibc). But it doesn't using the described version of FreeBSD grep. Curiously though: $ printf 'a^b$c' | grep -o '[a]^b' will match. And so too will 'b$c'. One can't portably rely on '\^' here to specify the literal '^', because POSIX-2008 says that '^' in non-anchoring positions is not special in BREs, and that the combination of '\' and a non-special character is undefined. Of course, neither can one use '[^]'. >How-To-Repeat: See above. >Fix: >Release-Note: >Audit-Trail: >Unformatted: