On Mon, Jul 19, 2021, at 2:00 PM, Greg Wooledge wrote:
> unicorn:~$ ksh
> $ echo $(('1' + 2))
> 51
>
> [...]
>
> Ksh officially wins "most surprising result" for that 51. I guess I
> can see how they got it, but I certainly did not *expect* it. Nor do I
> care to guess whether it satisfies the POSIX wording.
I think it does, insofar as the single quotes are retained (as they
would be within double quotes), and the expression resolves to
"'1' + 2". The surprise is that ksh arithmetic itself is extended
with this "casting" behavior. It works with `let` as well:
$ expr="x = '#' + '%'"
$ let "$expr"
$ typeset -p x
x=72
--
vq