Date: Mon, 2 Jun 2003 22:14:45 +0200 From: Jens Schweikhardt <schweikh@schweikhardt.net> To: standards@freebsd.org Subject: shell arithmetic not POSIX compliant Message-ID: <20030602201445.GA3650@schweikhardt.net>
index | next in thread | raw e-mail
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
<quote IEEE Std 1003.1, 2003 Edition>
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.
</quote IEEE Std 1003.1, 2003 Edition>
So it appears all assignment ops like += must be supported.
Regards,
Jens
--
Jens Schweikhardt http://www.schweikhardt.net/
SIGSIG -- signature too long (core dumped)
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030602201445.GA3650>
