On 6/21/21 5:57 AM, arnold(a)skeeve.com wrote:
Arithmetic expansion dates back at least as far as
ksh88.
ksh had the `let' builtin from at least 1983. The ((...)) compound command
was there by ksh-86.
Bash likely picked it up from there.
Sort of, see below.
The original was only integer math and Bash remains
that way (IIRC,
Chet can correct me if I'm wrong). ksh93 added floating point math.
Yes, bash only has integer arithmetic, since it's all POSIX requires.
POSIX would have picked it up from ksh88.
The $((...)) form of arithmetic expansion is something POSIX picked up
from ksh-88, eventually. The early drafts of the standard (through 1003.2
d9, at least), used $[...], but they eventually adopted $((...)) because
ksh-88 had already implemented it, though it's not documented in Bolsky
and Korn.
I put $[...] into bash first (it's still there, though deprecated), then
`let', then $((...)) after POSIX added it, and finally `((' for
compatibility.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet(a)case.edu
http://tiswww.cwru.edu/~chet/