From owner-freebsd-standards@FreeBSD.ORG Sun Jun 22 23:32:58 2003 Return-Path: Delivered-To: freebsd-standards@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EF6A837B401; Sun, 22 Jun 2003 23:32:58 -0700 (PDT) Received: from smtp.des.no (37.80-203-228.nextgentel.com [80.203.228.37]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8B9AC43FAF; Sun, 22 Jun 2003 23:32:57 -0700 (PDT) (envelope-from des@des.no) Received: by smtp.des.no (Postfix, from userid 666) id 877059595C; Mon, 23 Jun 2003 08:32:56 +0200 (CEST) Received: from dwp.des.no (dwp.des.no [10.0.0.4]) by smtp.des.no (Postfix) with ESMTP id B201B95958; Mon, 23 Jun 2003 08:32:55 +0200 (CEST) Received: by dwp.des.no (Postfix, from userid 2602) id 70E5EB823; Mon, 23 Jun 2003 08:32:55 +0200 (CEST) To: Wartan Hachaturow References: <200306222150.h5MLoGpX061341@freefall.freebsd.org> From: des@des.no (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=) Date: Mon, 23 Jun 2003 08:32:55 +0200 In-Reply-To: <200306222150.h5MLoGpX061341@freefall.freebsd.org> (Wartan Hachaturow's message of "Sun, 22 Jun 2003 14:50:16 -0700 (PDT)") Message-ID: User-Agent: Gnus/5.090024 (Oort Gnus v0.24) Emacs/21.2 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, hits=-3.0 required=8.0 tests=EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,USER_AGENT_GNUS_UA version=2.55 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp) cc: freebsd-gnats-submit@freebsd.org cc: freebsd-standards@FreeBSD.org Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jun 2003 06:32:59 -0000 Wartan Hachaturow writes: > The following reply was made to PR standards/52972; it has been noted by = GNATS. > On Sun, Jun 22, 2003 at 10:43:27PM +0200, Jens Schweikhardt wrote: > > The recursive processing requires that $(($a+1)) needs to undergo > > parameter expansion within $(()). >=20=20 > Right, but this construction works in /bin/sh: >=20=20 > wart@mojo:~$ /bin/sh > $ a=3D1 > $ echo $(($a+1)) > 2 Yes. It expands to $((1+1)) which evaluates to 2. > You've said the problem was with the variable without leading $, like > this: > $ a=3D1 > $ echo $((a+1))=20 > arith: syntax error: "a+1" This *should* work, but doesn't. > And, as far as my English allows me to judge, the quoted part of SUS > says that "a" in this construct should be left in output as is (since it > doesn't have leading $, ${, $(, etc.), shouldn't it? Yes, it should be left as-is so the part of the code that evaluates arithmetic expressions knows what variable is involved. For instance, "$(($a+=3D1)) would expand to "$((1+=3D1))" before evaluation, which makes no sense, while "$((a+=3D1))" clearly says to increase a with 1. DES --=20 Dag-Erling Sm=F8rgrav - des@des.no