← Commit list

9abf53beb

Denys Vlasenko
Denys Vlasenko
2018-08-05
SUCCESS Duration: 146s

Subject

ash: eval: Variable assignments on functions are no longer persistent

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/ash.c+0 -3
@@ -9600,9 +9600,7 @@ evalfun(struct funcnode *func, int argc, char **argv, int flags)
shellparam.optind = 1;
shellparam.optoff = -1;
#endif
- pushlocalvars();
evaltree(func->n.ndefun.body, flags & EV_TESTED);
- poplocalvars(0);
funcdone:
INT_OFF;
funcline = savefuncline;
@@ -10235,7 +10233,6 @@ evalcommand(union node *cmd, int flags)
goto readstatus;
case CMDFUNCTION:
- poplocalvars(1);
/* See above for the rationale */
dowait(DOWAIT_NONBLOCK, NULL);
if (evalfun(cmdentry.u.func, argc, argv, flags))
shell/ash_test/ash-misc/env_and_func.right+1 -1
@@ -1,2 +1,2 @@
var=val
-var=val
+var=old
shell/ash_test/ash-misc/env_and_func.tests+1 -1
@@ -3,6 +3,6 @@ f() { echo "var=$var"; }
# bash: POSIXLY_CORRECT behavior is to "leak" new variable values
# out of function invocations (similar to "special builtins" behavior);
# but in "bash mode", they don't leak.
-# hush does not "leak" values. ash does.
+# hush does not "leak" values. ash used to, but now does not.
var=val f
echo "var=$var"
shell/ash_test/ash-vars/var_leak.right+1 -1
@@ -1,4 +1,4 @@
should be empty: ''
should be empty: ''
should be not empty: 'val2'
-should be not empty: 'val3'
+should be empty: ''
shell/ash_test/ash-vars/var_leak.tests+1 -3
@@ -15,9 +15,7 @@ VAR=''
VAR=val2 exec 2>&1
echo "should be not empty: '$VAR'"
-# ash follows the "function call is a special builtin" rule here
-# (bash does not do it)
f() { true; }
VAR=''
VAR=val3 f
-echo "should be not empty: '$VAR'"
+echo "should be empty: '$VAR'"
shell/hush_test/hush-misc/env_and_func.tests+1 -1
@@ -3,6 +3,6 @@ f() { echo "var=$var"; }
# bash: POSIXLY_CORRECT behavior is to "leak" new variable values
# out of function invocations (similar to "special builtins" behavior);
# but in "bash mode", they don't leak.
-# hush does not "leak" values. ash does.
+# hush does not "leak" values. ash used to, but now does not.
var=val f
echo "var=$var"