Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 338438 - app-shells/posh: variable assignments do not affect the env when calling a function
Summary: app-shells/posh: variable assignments do not affect the env when calling a fu...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High major
Assignee: Michał Górny
URL: http://bugs.debian.org/cgi-bin/bugrep...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-23 12:20 UTC by Michał Górny
Modified: 2010-10-01 12:58 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.