From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 79485 invoked by alias); 28 Aug 2019 13:22:22 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 79472 invoked by uid 89); 28 Aug 2019 13:22:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,KAM_NUMSUBJECT,SPF_HELO_PASS autolearn=no version=3.3.1 spammy=bre X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 28 Aug 2019 13:22:21 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AF287307D8E3; Wed, 28 Aug 2019 13:22:19 +0000 (UTC) Received: from [10.3.116.234] (ovpn-116-234.phx2.redhat.com [10.3.116.234]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 63C0F5DA21; Wed, 28 Aug 2019 13:22:19 +0000 (UTC) Subject: Re: bug with grep 3.0.2 in cygwin 3.0.7 To: cygwin@cygwin.com, akiki@free.fr References: <1207614124.1217647925.1566976580120.JavaMail.root@zimbra76-e14.priv.proxad.net> From: Eric Blake Openpgp: preference=signencrypt Message-ID: Date: Wed, 28 Aug 2019 13:33:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <1207614124.1217647925.1566976580120.JavaMail.root@zimbra76-e14.priv.proxad.net> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="X73jsZm906is6BbcmSl8sqULB74J0QhPL" X-IsSubscribed: yes X-SW-Source: 2019-08/txt/msg00366.txt.bz2 --X73jsZm906is6BbcmSl8sqULB74J0QhPL Content-Type: multipart/mixed; boundary="oIaZNzH2iScvKMkpIsMBUxw8gom7cLWHO"; protected-headers="v1" From: Eric Blake To: cygwin@cygwin.com, akiki@free.fr Message-ID: Subject: Re: bug with grep 3.0.2 in cygwin 3.0.7 References: <1207614124.1217647925.1566976580120.JavaMail.root@zimbra76-e14.priv.proxad.net> In-Reply-To: <1207614124.1217647925.1566976580120.JavaMail.root@zimbra76-e14.priv.proxad.net> --oIaZNzH2iScvKMkpIsMBUxw8gom7cLWHO Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Content-length: 2080 On 8/28/19 2:16 AM, akiki@free.fr wrote: > Hi,=20 > I encounter some problem with grep option -E on cygwin 3.0.7=20 >=20 >=20 > echo "a^b" | grep "a^b" #answer a^b ie it's OK=20 POSIX says: https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html "A BRE special character has special properties in certain contexts. Outside those contexts, or when preceded by a , such a character is a BRE that matches the special character itself." ... "A ( '^' ) shall be an anchor when used as the first character of an entire BRE. The implementation may treat the as an anchor when used as the first character of a subexpression." Since ^ is only special as the first character or in a [], and you have used it for neither, this is a well-specified literal match. > but=20 > echo "a^b" | grep -E "a^b" #answer nothing " for me it's KO=20 "An ERE special character has special properties in certain contexts. Outside those contexts, or when preceded by a , such a character shall be an ERE that matches the special character itself." "A ( '^' ) outside a bracket expression shall anchor the expression or subexpression it begins to the beginning of a string; such an expression or subexpression can match only a sequence starting at the first character of a string. For example, the EREs "^ab" and "(^ab)" match "ab" in the string "abcdef", but fail to match in the string "cdefab", and the ERE "a^b" is valid, but can never match because the 'a' prevents the expression "^b" from matching starting at the first character." So in ERE, ^ is an anchor anywhere, while in BRE, ^ is an anchor only as the first byte. The difference you are observing matches POSIX. >=20 >=20 > I have to backslash ^ to be OK like : grep -E 'a\^b'=20 Correct. >=20 >=20 > Is-it a bug ?=20 No. (In fact, if you test on Linux, you'll see the same behavior, which shows it is not specific to Cygwin). --=20 Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org --oIaZNzH2iScvKMkpIsMBUxw8gom7cLWHO-- --X73jsZm906is6BbcmSl8sqULB74J0QhPL Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" Content-length: 488 -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEccLMIrHEYCkn0vOqp6FrSiUnQ2oFAl1mgAoACgkQp6FrSiUn Q2raWwgAklzudQ0Eyl0Lax7CG2ewRA7+e5IUdlYl9Slim+irPT7zqr2InDnWnD4F zsUZaYcuPG8gKR6zQhxfUpOHiLwN36XL4YFvegGoC6W5EFwvbKG0W4lskFww3xgK aCfPPYEF4CxXTDwu+VtYs0fAFkzWzSdIfqiMn2l2qNboUGsgGCU+41M0K3Jx134T rhZr3s5MbSHwRLdtsGbf3uRtDr/fVmjQk4QBMApwB1mel1lsUEVps8682tJPiHlW tlWknor94jPnpEIYc7sI1EtH9JDWiwEWOi+V/zhm8Ti64r7ZPm5TQo149m8D41qH 1WqMNR+PUp8XzyNdRnMlbg4Aj0ASxg== =vveG -----END PGP SIGNATURE----- --X73jsZm906is6BbcmSl8sqULB74J0QhPL--