Hello. I am currently writing a $(()) expression parser, using Dijkstra's two stack algorithm (heavily impressed by the busybox one). While doing so i encountered diverging behaviour in between shells, and a bug in dash (and a memory failure in NetBSD 9 ksh). For my own thing i hope i end up like bash (that is: just do it (tm)), but the NetBSD and OpenBSD variants i also like, as they mimic C and give an understandable error message. I Cc: some of you, just for your interest. Ciao. == Name: dash Path: /usr/ports/core Version: 0.5.11.5 #?2|kent:$ dash -c '(i=10; echo $((++-+++i)))' -10 #?2|kent:$ dash -c '(i=10; echo $((+++++i)))' 10 #?0|kent:vm$ dash -c '(i=10; echo $((+ + + ++i)))' 10 == GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu) #?0|kent:$ bash -c '(i=10; echo $((++-+++i)))' -11 == BusyBox v1.34.0 (2022-01-03 21:34:20 CET) multi-call binary. #?0|kent:$ busybox.static sh -c '(i=10; echo $((++-+++i)))' sh: arithmetic syntax error #?0|kent:$ busybox.static sh -c '(i=10; echo $((+ + - + ++i)))' -11 == FreeBSD 13.1-RELEASE releng/13.1-n250148-fc952ac2212 GENERIC FreeBSD 13.1 #|f-1301-x86:~$ sh -c '(i=10; echo $((++-+++i)))' sh: arithmetic expression: expecting primary: "++-+++i" == OpenBSD 7.1 (GENERIC.MP) #465: Mon Apr 11 18:03:57 MDT 2022 #?1|o-0701:steffen$ ksh -c '(i=10; echo $((++-+++i)))' ksh: ++-+++i: ++ requires lvalue #?1|o-0701:steffen$ ksh -c '(i=10; echo $((+++i)))' ksh: +++i: ++ requires lvalue #?1|o-0701:steffen$ ksh -c '(i=10; echo $((++i)))' 11 #?0|o-0701:steffen$ ksh -c '(i=10; echo $((+ + + ++i)))' 11 #?0|o-0701:steffen$ ksh -c '(i=10; echo $((+ + - + ++i)))' -11 == NetBSD n-0900 9.0 NetBSD 9.0 (GENERIC) #0: Fri Feb 14 00:06:28 UTC 2020 mkrepro@xxxxxxxxxxxxxxxxxx:/usr/src/sys/arch/amd64/compile/GENERIC amd64 #?0|n-0900:steffen$ ksh -c '(i=10; echo $((++-+++i)))' Memory fault #?2|n-0900:steffen$ sh -c '(i=10; echo $((+++++i)))' sh: arithmetic expression: incr/decr require var name: "+++++i" #?2|n-0900:steffen$ sh -c '(i=10; echo $((+ ++i)))' 11 #?0|n-0900:steffen$ sh -c '(i=10; echo $((+ - ++i)))' -11 --steffen | |Der Kragenbaer, The moon bear, |der holt sich munter he cheerfully and one by one |einen nach dem anderen runter wa.ks himself off |(By Robert Gernhardt)