On 03/09/2024 19:52, Martijn Dekker via austin-group-l at The Open Group
wrote:
Op 02-09-2024 om 21:30 schreef Steffen Nurpmeso via austin-group-l at
The Open Group:
At times you even get answers like "we already do more than
required", but noone understands why "+10++11" is a correctly
handled case, whereas "+10++VAR" is not, and if you generate
In ksh, this is an error:
$ echo $((+10++11))
-ksh: +10++11: assignment requires lvalue
Does POSIX require this to work? ksh is finding an incorrect use of the
++ increment prefix operator. Correct is:
$ echo $((+10+ +11))
21
POSIX does not require ++ to be implemented but does not forbid it
either. It says:
The sizeof() operator and the prefix and postfix "++" and "--"
operators are not required.
It is fine for shells to implement features that are not required, and
if the "++" feature is implemented, it is correct for it to result in an
error in this example, the C rules that POSIX defers to specify that
this is treated as a ++, not two consecutive +s, even if that then
results in a syntax error.
Cheers,
Harald van Dijk