Variable assignments on a command line invoking a shell function persist in the local environment, eg: BusyBox v1.22.1 (Ubuntu 1:1.22.0-15ubuntu1) built-in shell (ash) Enter 'help' for a list of built-in commands. ~ $ expecting() { > echo "Expecting ${EXP:-0}" > } ~ $ expecting Expecting 0 ~ $ EXP=1 expecting Expecting 1 ~ $ expecting Expecting 1 ~ $ This behaviour is to be modified in DASH to match its manual page, which says "... The variables which are explicitly placed in the environment of the command (by placing assignments to them before the function name) are made local to the function and are set to the values given. ..." by the patch at https://www.mail-archive.com/dash@vger.kernel.org/msg01579.html, as attached. The undesirable persistent behaviour was apparently a former POSIX requirement. In case people expect busybox/ash, which I don't think has its own man page, to behave in this way, can a similar change be applied to Busybox? The affected lines in Busybox are shell/ash.c:10199 for the first change and shell/ash.c:9564-6 for the second.
Created attachment 7556 [details] Patch from DASH
Not in dash git yet.
Fixed in git.