Date: Tue, 15 Aug 2017 23:28:50 -0700 From: "Ngie Cooper (yaneurabeya)" <yaneurabeya@gmail.com> To: KIRIYAMA Kazuhiko <kiri@kx.openedu.org> Cc: freebsd-current@freebsd.org Subject: Re: BSD awk bug ? Message-ID: <01859567-67AA-4706-BB90-84AF8E0C6208@gmail.com> In-Reply-To: <201708160315.v7G3FlAV081765@kx.openedu.org> References: <201708160114.v7G1EkxS079546@kx.openedu.org> <20170816013634.GA8152@tomoyat1.com> <201708160315.v7G3FlAV081765@kx.openedu.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail=_2169727D-6ABE-4924-84C1-CCD1EBF55871 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Aug 15, 2017, at 20:15, KIRIYAMA Kazuhiko <kiri@kx.openedu.org> = wrote: >=20 > At Wed, 16 Aug 2017 10:36:36 +0900, > Tomoya Tabuchi wrote: >>=20 >> On Wed, Aug 16, 2017 at 10:14:46AM +0900, KIRIYAMA Kazuhiko wrote: >>> admin@tbedfpc:~/tmp % ll >>> total 12 >>> -rw-r--r-- 1 admin admin 235 Aug 16 10:01 regex-1.sh >>> -rw-r--r-- 1 admin admin 236 Aug 16 10:01 regex-2.sh >>> -rw-r--r-- 1 admin admin 260 Aug 16 10:01 regex.sh >>> admin@tbedfpc:~/tmp % cat regex.sh >>> #!/bin/sh >>>=20 >>> data=3D'1 2 3 4 5 6 >>> 1 2 3 4 5 >>> 1 2 3 4 5 6 >>> 1 2 3 4 5 6 >>> 1 2 3 4 >>> 1 2 3' >>>=20 >>> IFS=3D$'\n' >>> for datum in $data; do >>> if echo "$datum" | egrep -q '^([^[:space:]]+[[:space:]]+){5}'; = then >>> echo "$datum" >>> else >>> echo "Not 6 components! : \"$datum\"" >>> fi >>> done >>> admin@tbedfpc:~/tmp % sh ./regex.sh >>> 1 2 3 4 5 6 >>> Not 6 components! : "1 2 3 4 5" >>> 1 2 3 4 5 6 >>> 1 2 3 4 5 6 >>> Not 6 components! : "1 2 3 4" >>> Not 6 components! : "1 2 3" >>> admin@tbedfpc:~/tmp % cat regex-1.sh >>> #!/bin/sh >>>=20 >>> _f_awk=3D' >>> { >>> if ($0 ~ /^([^[:space:]]+[[:space:]]+){5}/) { >>> print $0 >>> } else { >>> print "Not 6 components! : \"" $0 "\"" >>> } >>> }' >>>=20 >>> data=3D'1 2 3 4 5 6 >>> 1 2 3 4 5 >>> 1 2 3 4 5 6 >>> 1 2 3 4 5 6 >>> 1 2 3 4 >>> 1 2 3' >>>=20 >>> echo "$data" | awk "$_f_awk" >>> admin@tbedfpc:~/tmp % sh ./regex-1.sh >>> Not 6 components! : "1 2 3 4 5 6" >>> Not 6 components! : "1 2 3 4 5" >>> Not 6 components! : "1 2 3 4 5 6" >>> Not 6 components! : "1 2 3 4 5 6" >>> Not 6 components! : "1 2 3 4" >>> Not 6 components! : "1 2 3" >>> admin@tbedfpc:~/tmp % cat regex-2.sh >>> #!/bin/sh >>>=20 >>> _f_awk=3D' >>> { >>> if ($0 ~ /^([^[:space:]]+[[:space:]]+){5}/) { >>> print $0 >>> } else { >>> print "Not 6 components! : \"" $0 "\"" >>> } >>> }' >>>=20 >>> data=3D'1 2 3 4 5 6 >>> 1 2 3 4 5 >>> 1 2 3 4 5 6 >>> 1 2 3 4 5 6 >>> 1 2 3 4 >>> 1 2 3' >>>=20 >>> echo "$data" | gawk "$_f_awk" >>> admin@tbedfpc:~/tmp % sh ./regex-2.sh >>> 1 2 3 4 5 6 >>> Not 6 components! : "1 2 3 4 5" >>> 1 2 3 4 5 6 >>> 1 2 3 4 5 6 >>> Not 6 components! : "1 2 3 4" >>> Not 6 components! : "1 2 3" >>> admin@tbedfpc:~/tmp % uname -a >>> FreeBSD tbedfpc 12.0-CURRENT FreeBSD 12.0-CURRENT #0 r321597: Thu = Jul 27 12:30:57 UTC 2017 root@tbedfc:/usr/obj/usr/src/sys/GENERIC = amd64 >>> admin@tbedfpc:~/tmp % pkg info -aI|grep gawk >>> gawk-4.1.4_1 GNU version of Awk >>> admin@tbedfpc:~/tmp % >>>=20 >>>=20 >>> Is this the BSD awk (/usr/bin/awk) bug ? >>=20 >> Hello Kiriyama-san, >>=20 >> The man page awk(1) says that {m,n} matcning is not supported. The = "{5}" >> part matches the literal sequence of characters it's made out of, I = suppose. >=20 > Oops. I missed "STANDARDS" section. Thanks for pointed out. >=20 > # But as it says in front "awk supports extended regular > # expressions (EREs). See re_format(7) for more information > # on regular expressions.", I'd like to coinside with > # re_format(7) spec. Hello Kiriyama-san, I asked this same question a while back and was told that the = {n} form didn=E2=80=99t work with nawk. I=E2=80=99ll have to dig up the = exact post if it=E2=80=99s somewhere public. Cheers, -Ngie --Apple-Mail=_2169727D-6ABE-4924-84C1-CCD1EBF55871 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJZk+YiAAoJEPWDqSZpMIYVU14P/0nDFQM3l1iLXHR+ezDBNbVg mIxRAl7a2lgSeZLr+pt7GENf7M9WJMxZ7ErV7wtk6J6BhAUvKQMwdBGVzvCP1g9I FKxM4onLvxuVTY/pO93jhZrHLPn+VslD3vQTRuPKae6jELeK4HE6srmKHfrmhMeV 9EPent0o49Bgy+OWTOT0L2xaDdcCtQSfggYa/zCkMYcq9gvTaeYt0ZOd0pTsjmTt ht5t7BfPBu2wAnijVfmn4BEiycuk0tsWCOaPrtsoLcoO4nAUOayF6hgqrzVkYMdO Rl4H9OvZYF4cOBFDA0/Y56rgCKwwgzhyBTYoZbBoRrx4R029PeostM1cosWwewEg PjNA2RHc5ICWZIqFgJZlSiBzrk/W7Nk12MAOxmQQzgpBe2ceNwKBIlk19BQDY9Rs M+2WJMl0LA0tVK7koap++bTFRNxzN+433GwejPHc4/CRj+g1zMC3YzIVYfi3RXTP YXyXyLXXRM6a/F2bPkwpto1t4MmyTsOFomiVnh0F/eT7zLo223q9Yl579H5mjG6t DwppEaCFgNQ+nT2AitBY7KFCU1VRgWlZ3kncWqHRPT02MKShuKf/9UYed9qGeSqZ uJ+MShppBP9BDC4UatAMu6+4VuY6xp7ekn3PpunFELKvH1l8XXP0+N2HbUw7bR3/ q5wHXDm2Ik/DokXXKvNY =Z11A -----END PGP SIGNATURE----- --Apple-Mail=_2169727D-6ABE-4924-84C1-CCD1EBF55871--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?01859567-67AA-4706-BB90-84AF8E0C6208>