Op 19-01-17 om 21:06 schreef Michael Greenberg: > unset x ; echo $((x+=2)) > > Running bash on this program echoes the number 2 to standard out and sets x to 2. Running dash (git HEAD/release 0.5.9.1) yields an error: > > src/dash: 1: Illegal number: Yes, looks like a dash-specific bug. The related shells Busybox ash and FreeBSD /bin/sh act like POSIX says they should. > The standard is a little bit unclear about what to do for variables that are set to null (or non-numeric values). I’d interpret the standard as defaulting for unset variables, having null and other non-numeric strings cause some kind of error. bash, as usual, goes well beyond what the standard indicates: any non-numerical value is defaulted to 0. So: > > x="" ; echo $((x+=2)) > > x=“yo” ; echo $((x+=2)) > > both yield 2! If you ask me, that’s a bridge too far—and asking for bugs. That's recursive arithmetic expression parsing in bash, ksh and zsh; if the value of a variable is an arithmetic expression (including simply another variable name, such as "yo") this is evaluated, which in this case means the value of "x" is taken as the value of "yo" which is taken as zero. That behaviour is not specified by POSIX, of course. - M. -- To unsubscribe from this list: send the line "unsubscribe dash" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html