From owner-freebsd-standards@FreeBSD.ORG Mon Jun 2 13:14:32 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 2351E37B404 for ; Mon, 2 Jun 2003 13:14:31 -0700 (PDT) Received: from bremen.shuttle.de (bremen.shuttle.de [194.95.249.251]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3CD7943F85 for ; Mon, 2 Jun 2003 13:14:30 -0700 (PDT) (envelope-from schweikh@schweikhardt.net) Received: from bremen.shuttle.de (localhost [127.0.0.1]) by bremen.shuttle.de (Postfix) with ESMTP id AD17517D2D for ; Mon, 2 Jun 2003 22:14:28 +0200 (CEST) Received: (from uucp@localhost)h52KES8i004400 for standards@freebsd.org; Mon, 2 Jun 2003 22:14:28 +0200 Received: (from schweikh@localhost) by hal9000.schweikhardt.net (8.12.9/8.12.9) id h52KEjRa004112 for standards@freebsd.org; Mon, 2 Jun 2003 22:14:45 +0200 (CEST) (envelope-from schweikh) Date: Mon, 2 Jun 2003 22:14:45 +0200 From: Jens Schweikhardt To: standards@freebsd.org Message-ID: <20030602201445.GA3650@schweikhardt.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.1i Subject: shell 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, 02 Jun 2003 20:14:32 -0000 hello, world\n while trying to configure the POSIX validation suite from the OpenGroup (VSC-lite) I ran into the following problem. During test script generation the following syntax appears in a shell script: : $((tet_l31_testnum += $#)) where tet_l31_testnum is the name of a variable with an integer value and $# is 1. Our /bin/sh complains about /home/vsctest1/tet_root/lib/posix_sh/tcm.sh: arith: syntax error: "tet_l31_testnum += 1" This begs the question is our shell's arithmetic substandard or is the bug in the script? I'm inclined to say it is a bug in our /bin/sh, reading the POSIX 2001 sh spec, which refers to the C operators table and makes these exceptions The arithmetic expression shall be processed according to the rules given in Arithmetic Precision and Operations , with the following exceptions: * Only signed long integer arithmetic is required. * 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. * The sizeof() operator and the prefix and postfix "++" and "--" operators are not required. * Selection, iteration, and jump statements are not supported. So it appears all assignment ops like += must be supported. Regards, Jens -- Jens Schweikhardt http://www.schweikhardt.net/ SIGSIG -- signature too long (core dumped)