The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: Chet Ramey <chet.ramey@case.edu>
To: arnold@skeeve.com, tuhs@minnie.tuhs.org, msi@malbolge.net
Subject: Re: [TUHS] Arithmetic expansion in Unix shells
Date: Mon, 21 Jun 2021 09:50:38 -0400	[thread overview]
Message-ID: <04536d5b-a6dd-4900-80de-4efc6824aa68@case.edu> (raw)
In-Reply-To: <202106210957.15L9vpZu004496@freefriends.org>

On 6/21/21 5:57 AM, arnold@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@case.edu    http://tiswww.cwru.edu/~chet/

  reply	other threads:[~2021-06-21 13:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-21  9:37 Michael Siegel
2021-06-21  9:57 ` arnold
2021-06-21 13:50   ` Chet Ramey [this message]
2021-06-21 14:43     ` Michael Siegel
2021-06-21 14:48       ` Chet Ramey
2021-06-22 16:24         ` Michael Siegel
2021-06-22 15:52 Brian Walden

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=04536d5b-a6dd-4900-80de-4efc6824aa68@case.edu \
    --to=chet.ramey@case.edu \
    --cc=arnold@skeeve.com \
    --cc=msi@malbolge.net \
    --cc=tuhs@minnie.tuhs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).