From owner-freebsd-standards@FreeBSD.ORG Mon Jun 23 11:30:15 2003 Return-Path: Delivered-To: freebsd-standards@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 494AF37B401 for ; Mon, 23 Jun 2003 11:30:15 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id BBFB943FF2 for ; Mon, 23 Jun 2003 11:30:14 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h5NIUEUp006713 for ; Mon, 23 Jun 2003 11:30:14 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h5NIUEM6006712; Mon, 23 Jun 2003 11:30:14 -0700 (PDT) Date: Mon, 23 Jun 2003 11:30:14 -0700 (PDT) Message-Id: <200306231830.h5NIUEM6006712@freefall.freebsd.org> To: freebsd-standards@FreeBSD.org From: des@des.no (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=) Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant X-BeenThere: freebsd-standards@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?= List-Id: Standards compliance List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 23 Jun 2003 18:30:15 -0000 The following reply was made to PR standards/52972; it has been noted by GNATS. From: des@des.no (Dag-Erling =?iso-8859-1?q?Sm=F8rgrav?=) To: Wartan Hachaturow Cc: freebsd-gnats-submit@freebsd.org Subject: Re: standards/52972: /bin/sh arithmetic not POSIX compliant Date: Mon, 23 Jun 2003 20:24:51 +0200 Wartan Hachaturow writes: > I've filed just the same bug against Debian package of ash. This is the > answer I got from Herbert Xu, also an upstream of what's called "dash", > Debian fork of ash shell (it has just the same behaviour as FreeBSD's=20 > ash): >=20 > > > According to SUSv3, shell should implement integer variables in=20 > > > arithmetic evaluation: > > > > You're mistaken. SUSv3 only requires constant arithmetic. Variables > > must be expanded before reaching arithmetic expansion. He's wrong. The full text of section 2.6.4 is: | Arithmetic expansion provides a mechanism for evaluating an arithmetic | expression and substituting its value. The format for arithmetic | expansion shall be as follows: |=20 | $((expression)) |=20 | The expression shall be treated as if it were in double-quotes, except | that a double-quote inside the expression is not treated | specially. The shell shall expand all tokens in the expression for | parameter expansion, command substitution, and quote removal. |=20 | Next, the shell shall treat this as an arithmetic expression and | substitute the value of the expression. The arithmetic expression | shall be processed according to the rules given in Arithmetic | Precision and Operations , with the following exceptions: |=20 | - Only signed long integer arithmetic is required. |=20 | - Only the decimal-constant, octal-constant, and hexadecimal-constant | constants specified in the ISO C standard, Section 6.4.4.1 are | required to be recognized as constants. |=20 | - The sizeof() operator and the prefix and postfix "++" and "--" | operators are not required. |=20 | - Selection, iteration, and jump statements are not supported. |=20 | As an extension, the shell may recognize arithmetic expressions beyond | those listed. The shell may use a signed integer type with a rank | larger than the rank of signed long. The shell may use a real-floating | type instead of signed long as long as it does not affect the results | in cases where there is no overflow. If the expression is invalid, the | expansion fails and the shell shall write a message to standard error | indicating the failure. Not only is there nothing there about only supporting constant artithmetic, but the assignment operators are *not* listed as exceptions to the "rules given in Arithmetic Precision and Operations", which refers to section 1.7.2.1, which you will find at the following URL: http://www.opengroup.org/onlinepubs/007904975/utilities/xcu_chap01.html#tag= _01_07_02_01 Therefore, assignment operators *are* required to work. DES --=20 Dag-Erling Sm=F8rgrav - des@des.no