My script keeps crashing in Busybox 1.27.2, so after some debugging I've discovered this behaviour: # sh # XXX=-1 # echo $((0-$XXX)) sh: arithmetic syntax error # echo $((0- $XXX)) 1 In GNU bash 4.4.12(1)-release the same code works: # sh # XXX=-1 # echo $((0-$XXX)) 1 # echo $((0- $XXX)) 1 It seems to be general for expressions even without variables like $((0--1)) with those results: # echo $((0--1)) -sh: arithmetic syntax error # echo $((0-+1)) -1 # echo $((0+-1)) -1 # echo $((0++1)) -sh: arithmetic syntax error
Fixed in git, thanks!