From owner-freebsd-standards@freebsd.org Wed Feb 20 16:51:19 2019 Return-Path: Delivered-To: freebsd-standards@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 388E214F8F1D for ; Wed, 20 Feb 2019 16:51:19 +0000 (UTC) (envelope-from bugzilla-noreply@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 BF5C8884BD for ; Wed, 20 Feb 2019 16:51:18 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.ysv.freebsd.org (Postfix) id 7E80814F8F1A; Wed, 20 Feb 2019 16:51:18 +0000 (UTC) Delivered-To: standards@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5A49314F8F19 for ; Wed, 20 Feb 2019 16:51:18 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.ysv.freebsd.org (mxrelay.ysv.freebsd.org [IPv6:2001:1900:2254:206a::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.ysv.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id CD911884B8 for ; Wed, 20 Feb 2019 16:51:17 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.ysv.freebsd.org (Postfix) with ESMTPS id EEFD21000F for ; Wed, 20 Feb 2019 16:51:16 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id x1KGpGWE012495 for ; Wed, 20 Feb 2019 16:51:16 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id x1KGpGIu012482 for standards@FreeBSD.org; Wed, 20 Feb 2019 16:51:16 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: standards@FreeBSD.org Subject: [Bug 235887] awk fails to replace "/ere/" with "$0 ~ /ere/" according to POSIX Date: Wed, 20 Feb 2019 16:51:16 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: standards X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: freebsd@tim.thechases.com X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: standards@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Feb 2019 16:51:19 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D235887 Bug ID: 235887 Summary: awk fails to replace "/ere/" with "$0 ~ /ere/" according to POSIX Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Many People Priority: --- Component: standards Assignee: standards@FreeBSD.org Reporter: freebsd@tim.thechases.com I've hit a case in which /ere/ doesn't expand the same as "$0 ~ /ere/" which it should do according to the POSIX spec[0]. The goal was to meet the criterion "one and only one of multiple regex matches", so I used jot 20 | awk '/1/ + /5/ =3D=3D 1' (this can be expanded for any number of expressions, e.g.=20 "/1/ + /5/ + /7/ =3D=3D 1", but the example using `jot 20` makes it easier to demonstrate the problem, looking for lines containing 1 or 5 but not 15) This gives a parse error: $ jot 20 | awk '/1/ + /5/ =3D=3D 1' awk: syntax error at source line 1 context is /1/ + >>> / <<<=20 awk: bailing out at source line 1 Strangely, wrapping the expressions in parens works as expected: $ jot 20 | awk '(/1/) + (/5/) =3D=3D 1' However manually performing the replacement documented above according to the POSIX spec: $ jot 20 | awk '$0 ~ /1/ + $0 ~ /5/ =3D=3D 1' parses fine (instead of giving the syntax error), so awk isn't doing the "/ere/ -> $0 ~ /ere/" replacement POSIXly. However, this also doesn't give results I'd consider correct (it returns "5" and "15"). Again, wrapping those expansions in parens gives the expected/correct results: $ jot 20 | awk '($0 ~ /1/) + ($0 ~ /5/) =3D=3D 1' As a side note, gawk parses the original notation ('/1/ + /5/ =3D=3D 1') fine and it does the same as the parenthesized versions above. -tkc [0] """ When an ERE token appears as an expression in any context other than as the right-hand of the '=CB=9C' or "!=CB=9C" operator or as one of the built-in function arguments described below, the value of the resulting expression shall be the equivalent of: $0 =CB=9C /ere/ """ http://pubs.opengroup.org/onlinepubs/009695399/utilities/awk.html --=20 You are receiving this mail because: You are the assignee for the bug.=