[Bug 10936] New: Variable assignment with function invocation persists

bugzilla at busybox.net bugzilla at busybox.net
Tue Apr 10 12:19:24 UTC 2018


https://bugs.busybox.net/show_bug.cgi?id=10936

            Bug ID: 10936
           Summary: Variable assignment with function invocation persists
           Product: Busybox
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P5
         Component: Other
          Assignee: unassigned at busybox.net
          Reporter: fieldhouse at gmx.net
                CC: busybox-cvs at busybox.net
  Target Milestone: ---

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the busybox-cvs mailing list