From owner-freebsd-hackers@freebsd.org Wed Nov 4 20:53:27 2015 Return-Path: Delivered-To: freebsd-hackers@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 BE494A266D2 for ; Wed, 4 Nov 2015 20:53:27 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id A9E551650 for ; Wed, 4 Nov 2015 20:53:27 +0000 (UTC) (envelope-from ian@freebsd.org) Received: by mailman.ysv.freebsd.org (Postfix) id A5B1BA266D1; Wed, 4 Nov 2015 20:53:27 +0000 (UTC) Delivered-To: hackers@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 A4579A266D0 for ; Wed, 4 Nov 2015 20:53:27 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from erouter6.ore.mailhop.org (erouter6.ore.mailhop.org [54.187.213.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7F5B3164F for ; Wed, 4 Nov 2015 20:53:27 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from ilsoft.org (unknown [73.34.117.227]) by outbound3.ore.mailhop.org (Halon Mail Gateway) with ESMTPSA; Wed, 4 Nov 2015 20:52:21 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.14.9/8.14.9) with ESMTP id tA4KrIPQ047280; Wed, 4 Nov 2015 13:53:18 -0700 (MST) (envelope-from ian@freebsd.org) Message-ID: <1446670398.91534.358.camel@freebsd.org> Subject: Re: awk's curly braces (regex) From: Ian Lepore To: rank1seeker@gmail.com, hackers@freebsd.org Date: Wed, 04 Nov 2015 13:53:18 -0700 In-Reply-To: <20151104211008.00006c16@gmail.com> References: <20151104211008.00006c16@gmail.com> Content-Type: text/plain; charset="us-ascii" X-Mailer: Evolution 3.16.5 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 04 Nov 2015 20:53:27 -0000 On Wed, 2015-11-04 at 21:10 +0100, rank1seeker@gmail.com wrote: > 10.2-RELEASE-p6 > > # awk --version > awk version 20121220 (FreeBSD) > > # echo 2015 | awk '/^[0-9]/ {print}' > Prints '2015' > > # echo 2015 | awk '/^[0-9]{4}/ {print}' > Won't > > Why range/interval specified via curly braces doesn't work. > PS: Yes I've tried escaping it with backslahes and double backslahes, > nada! > > man pages: > -- > Regular expressions are as in egrep; see grep(1). > -- For what it's worth, the manpage on a linux system I checked also says the regex is like egrep, but then it points out that one difference is "interval expressions" (curly brace stuff) which it says are "likely to break old awk programs" so they're only enabled if --posix or --re -interval options are given. Our awk doesn't seem to support those options. I guess our awk might also avoid the interval expressions out of caution for breaking old programs; maybe we need to add the options to enable them, like gnu awk has. -- Ian