From owner-freebsd-questions@freebsd.org Sun Jun 26 15:31:43 2016 Return-Path: Delivered-To: freebsd-questions@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 59E3BB81618 for ; Sun, 26 Jun 2016 15:31:43 +0000 (UTC) (envelope-from matthew@FreeBSD.org) Received: from smtp.infracaninophile.co.uk (smtp.infracaninophile.co.uk [81.2.117.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "smtp.infracaninophile.co.uk", Issuer "infracaninophile.co.uk" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id E1DE223F4 for ; Sun, 26 Jun 2016 15:31:42 +0000 (UTC) (envelope-from matthew@FreeBSD.org) Received: from liminal.local (liminal.infracaninophile.co.uk [IPv6:2001:8b0:151:1:3636:3bff:fed4:b0d6]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: m.seaman@infracaninophile.co.uk) by smtp.infracaninophile.co.uk (Postfix) with ESMTPSA id 97452289B for ; Sun, 26 Jun 2016 15:31:31 +0000 (UTC) Authentication-Results: smtp.infracaninophile.co.uk; dmarc=none header.from=FreeBSD.org Authentication-Results: smtp.infracaninophile.co.uk/97452289B; dkim=none; dkim-atps=neutral Subject: Re: grep and anchoring To: freebsd-questions@freebsd.org References: <20232C89-B821-41EC-9188-C2A19C679BD8@danieldk.eu> <20160626163411.d05f863e.freebsd@edvax.de> <362EE01F-4B49-4ADB-A3A6-43F852FFF87F@danieldk.eu> From: Matthew Seaman Message-ID: <9fc6d5df-108b-5663-5a31-92ca915a9604@FreeBSD.org> Date: Sun, 26 Jun 2016 16:31:20 +0100 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 MIME-Version: 1.0 In-Reply-To: <362EE01F-4B49-4ADB-A3A6-43F852FFF87F@danieldk.eu> Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Mx7clcHsOgU5K57EMCdXS3BqKKPefVEU5" X-Virus-Scanned: clamav-milter 0.99.2 at smtp.infracaninophile.co.uk X-Virus-Status: Clean X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,SPF_SOFTFAIL autolearn=no autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on smtp.infracaninophile.co.uk X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Jun 2016 15:31:43 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --Mx7clcHsOgU5K57EMCdXS3BqKKPefVEU5 Content-Type: multipart/mixed; boundary="sW8TwXFtt3AOEitUhmr2kcME38IwPGF7n" From: Matthew Seaman To: freebsd-questions@freebsd.org Message-ID: <9fc6d5df-108b-5663-5a31-92ca915a9604@FreeBSD.org> Subject: Re: grep and anchoring References: <20232C89-B821-41EC-9188-C2A19C679BD8@danieldk.eu> <20160626163411.d05f863e.freebsd@edvax.de> <362EE01F-4B49-4ADB-A3A6-43F852FFF87F@danieldk.eu> In-Reply-To: <362EE01F-4B49-4ADB-A3A6-43F852FFF87F@danieldk.eu> --sW8TwXFtt3AOEitUhmr2kcME38IwPGF7n Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 26/06/2016 15:44, Dani=C3=ABl de Kok wrote: > Note the anchoring (^), the pattern should only match any four characte= rs at the beginning of the line, so the expected output is =E2=80=981234=E2= =80=99 and nothing more. =E2=80=98 123' and '4 12' are not at the beginni= ng of the line and should consequently not be printed to stdout. >=20 > For comparison, the output of a recent GNU grep: >=20 > =E2=80=94 > % echo "1234 1234 1234" | grep -o '^....' > 1234 > =E2=80=94 You are completely correct -- this is a bug in grep(1) on FreeBSD. In all current releases including the upcoming 11.0-RELEASE grep is actually GNU grep version 2.1.5. However, the same bug occurs in bsdgrep(1): % echo 1234 1234 1234 | bsdgrep -o '^....' 1234 123 4 12 There is already an open PR about a very similar issue: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D201650 Could you update that PR with your findings? Especially that bsdgrep(1) also shows the same problem. Cheers, Matthew --sW8TwXFtt3AOEitUhmr2kcME38IwPGF7n-- --Mx7clcHsOgU5K57EMCdXS3BqKKPefVEU5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQJ8BAEBCgBmBQJXb/VOXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXQ2NTNBNjhCOTEzQTRFNkNGM0UxRTEzMjZC QjIzQUY1MThFMUE0MDEzAAoJELsjr1GOGkAT+2YQAIXTdNVD8eWikrPzJH+pTTU8 v6rjLcuTVA61pz6eZfyIBSMSik76lLxN2NHDSeIpvkjH4Ff0u8TAb2FRdEDj/XVL RR6BTr97+2A36UMEvEsnolUoQlJSI0P5SL4arMSqz0McjFDH6gS8bDyALh5e9AkT kh0Iw9SN//VJuLkXkLrTIUIXlKcfgxtKMHWdNIZo+33wWzkRvfvt8cUN+l4mmFG/ Er56q3fHlgXKwGdqS+9WuTCd922GBqLrWSx4i9buLxueKbsgAueRpU9nN7chpKvx QbrXVfgSbphKM+ZpuEd723gIWob4xObnWUjwjaE6qquX7R34QcAw1/1mDx0MsM1G cSliDVT3McYaAz/08avKQW0g5ZhwGqbJPL9q27LL27RduTHGZfjK1enBpm1Pep4Z wgx8oCh3RLz5VyuJvZKBzIv3z8ly+3WPy2BDYCCyaadUNMpRzJixK24XaVdpdd3O lbFfC76HT+xR066EEKnpQ1E8VJf17+Kusy3bJySeMj5m6OOGHQ4EMe4diIxNbj09 AE+tivkEK6kxWhu2OpYDpQYhl2H2H3WroZrZ6o2YzvcDdYlxuhb+wFVy1mQ0XDHr d3emtBmNjYnGGWg9ZeOjCYGbV9zLu65zuG1tiLdyYQzdKLEu6ijLhAfNbEvsfUgS +Z/HtEEN5ar/zmZM3Mac =1cHr -----END PGP SIGNATURE----- --Mx7clcHsOgU5K57EMCdXS3BqKKPefVEU5--