the toybox project is adding a shell, and came across this issue that i (Android native tools/libraries maintainer) have hit before because mksh does exactly what POSIX says and bash does what POSIX probably intended: http://lists.landley.net/pipermail/toybox-landley.net/2019-June/010530.html
repeated here, lightly edited and extended, because i know there are plenty of shell folks here: I've reached the part of the posix shell stuff (section 2.9.1: simple commands) that specifies this behavior, and posix doesn't match bash: If no command name results, or if the command name is a special built-in or function, variable assignments shall affect the current execution environment. Otherwise, the variable assignments shall be exported for the execution environment of the command and shall not affect the current execution environment except as a side-effect of the expansions performed in step 4. A) This is not what bash does, or has ever done: $ hello() { echo boing=$BOING; } $ BOING=123 hello $ echo $BOING $ B) doing it isn't useful because there's no reason to DO an assignment on the same line rather than on the previous line unless you want to constrain the lifetime of the variables. (The semicolon character exists, you can do X=y; echo $X; It's literally one extra character.) but here's mksh: ~$ mksh $ hello() { echo boing=$BOING; } $ BOING=123 hello boing=123 $ echo $BOING 123 $ and ksh, since that seems to come up on this list: $ ksh ~ [1]$ hello() { echo boing=$BOING; } ~ [2]$ BOING=123 hello boing=123 ~ [3]$ echo $BOING 123 ~ [4]$ zsh also agrees. so it seems like bash is the exception (but bash is also the most useful?).