Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 338438

Summary: app-shells/posh: variable assignments do not affect the env when calling a function
Product: Gentoo Linux Reporter: Michał Górny <mgorny>
Component: [OLD] Core systemAssignee: Michał Górny <mgorny>
Status: CONFIRMED ---    
Severity: major    
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
URL: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=598236
Whiteboard:
Package list:
Runtime testing required: ---

Description Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-09-23 12:20:14 UTC
app-shells/dash fails to correctly limit the scope of variable assignments when calling a function. Consider the following test code:

#v+
func() {true; }
RANDUM=a
RANDUM=b func
echo ${RANDUM}
#v-

In bash and posh, the above example output 'a'. In dash (tested 0.5.5.1.2 and 0.5.5.1.7), it outputs 'b'.

As SUS states, 'If no command name results, 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 for special built-ins)' [1]. Thus, I consider dash behaviour a bug.

[1] http://www.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_09_01
Comment 1 SpanKY gentoo-dev 2010-09-23 18:36:59 UTC
this is correct behavior.  bash does the same thing when invoked as /bin/sh.  it's even more obnoxious that bash changes its behavior based on how it was invoked.

http://lists.gnu.org/archive/html/bug-bash/2010-08/msg00164.html
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2010-09-23 18:51:03 UTC
Let's reuse the bug for reverse posh bugreport then.