busybox/shell/hush_test/hush-misc
Denys Vlasenko 9abf53beb4 ash: eval: Variable assignments on functions are no longer persistent
Upstream commit:

    Date: Wed, 4 Apr 2018 17:54:01 +0800
    eval: Variable assignments on functions are no longer persistent

    Dirk Fieldhouse <fieldhouse@gmx.net> wrote:
    > In POSIX.1-2017 ("simultaneously IEEE Std 1003.1™-2017 and The Open
    > Group Technical Standard Base Specifications, Issue 7")
    > <http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09>,
    > we read under '2.9.1 Simple Commands'
    >
    > "Variable assignments shall be performed as follows:
    > ...
    > -    If the command name is a standard utility implemented as a function
    > (see XBD Utility), the effect of variable assignments shall be as if the
    > utility was not implemented as a function.
    > ...
    > -    If the command name is a function that is not a standard utility
    > implemented as a function, variable assignments shall affect the current
    > execution environment during the execution of the function. It is
    > unspecified:
    >
    >     *   Whether or not the variable assignments persist after the
    > completion of the function
    >
    >     *   Whether or not the variables gain the export attribute during
    > the execution of the function
    >
    >     *   Whether or not export attributes gained as a result of the
    > variable assignments persist after the completion of the function (if
    > variable assignments persist after the completion of the function)"

    POSIX used to require the current dash behaviour.  However, you're
    right that this is no longer the case.

    This patch will remove the persistence of the variable assignment.

    I have considered the exporting the variables during the function
    execution but have decided against it because:

    1) It makes the code bigger.
    2) dash has never done this in the past.
    3) You cannot use this portably anyway.

    Reported-by: Dirk Fieldhouse <fieldhouse@gmx.net>
    Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

function                                             old     new   delta
evalcommand                                         1606    1635     +29
evalcase                                             313     317      +4
evalfun                                              280     268     -12
pushlocalvars                                         48       -     -48
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 2/1 up/down: 33/-60)            Total: -27 bytes

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2018-08-05 11:14:11 +02:00
..
and-or.right move hush-parsing/and-or.tests to hush-misc/* 2009-04-06 16:17:51 +00:00
and-or.tests move hush-parsing/and-or.tests to hush-misc/* 2009-04-06 16:17:51 +00:00
assignment1.right hush: fix mishandling of a'b'c=fff as assignments. They are not. 2008-08-04 00:46:07 +00:00
assignment1.tests hush: fix mishandling of a'b'c=fff as assignments. They are not. 2008-08-04 00:46:07 +00:00
assignment2.right hush testsuite: fix another false positive 2016-10-03 00:14:26 +02:00
assignment2.tests hush testsuite: fix another false positive 2016-10-03 00:14:26 +02:00
assignment3.right hush: fix improper handling of newline and hash chars in few corner cases 2010-11-22 17:58:14 +01:00
assignment3.tests hush: fix improper handling of newline and hash chars in few corner cases 2010-11-22 17:58:14 +01:00
assignment4.right hush: fix misparsing of "... do eval a= ...". Closes 3721 2011-05-14 11:27:36 +02:00
assignment4.tests hush: fix misparsing of "... do eval a= ...". Closes 3721 2011-05-14 11:27:36 +02:00
assignment5.right hush: fix "set -e; false || x=1; echo OK" 2018-04-03 11:21:13 +02:00
assignment5.tests hush: fix "set -e; false || x=1; echo OK" 2018-04-03 11:21:13 +02:00
break1.right hush: support "break N" and "continue N" 2008-07-28 23:07:06 +00:00
break1.tests *: trailing empty lines removed 2010-07-26 01:49:12 +02:00
break2.right hush: support "break N" and "continue N" 2008-07-28 23:07:06 +00:00
break2.tests hush: support "break N" and "continue N" 2008-07-28 23:07:06 +00:00
break3.right hush: support "break N" and "continue N" 2008-07-28 23:07:06 +00:00
break3.tests hush: support "break N" and "continue N" 2008-07-28 23:07:06 +00:00
break4.right hush: fix "while false; ..." exitcode; add testsuites 2008-07-28 23:17:31 +00:00
break4.tests hush: fix "while false; ..." exitcode; add testsuites 2008-07-28 23:17:31 +00:00
break5.right hush: fix break'ing out of {} and () groups; with testcase 2008-07-29 11:37:15 +00:00
break5.tests hush: fix break'ing out of {} and () groups; with testcase 2008-07-29 11:37:15 +00:00
builtin1.right hush: add #defines to switch off break/continue if loops are not supported 2008-07-29 10:16:05 +00:00
builtin1.tests hush: add #defines to switch off break/continue if loops are not supported 2008-07-29 10:16:05 +00:00
case1.right hush: fix problems with case in subshells and with "case esac" 2009-05-23 16:50:07 +02:00
case1.tests hush: fix problems with case in subshells and with "case esac" 2009-05-23 16:50:07 +02:00
colon.right hush: add support for ':'; create testsuite entries 2008-06-14 15:50:55 +00:00
colon.tests hush: fix a bug where we were requiring semicolon here: (cmd;) 2008-06-14 17:13:20 +00:00
command2.right hush: add command2.tests from ash tests 2018-01-12 17:58:20 +01:00
command2.tests hush: add command2.tests from ash tests 2018-01-12 17:58:20 +01:00
compound.right hush_test: add some pathological compound list tests 2009-05-21 18:35:37 -04:00
compound.tests make compound.tests executable 2009-05-23 17:00:13 +02:00
continue1.right hush: small fix for repeated continue and fix for wrong loop depth count 2008-07-29 13:36:09 +00:00
continue1.tests hush: small fix for repeated continue and fix for wrong loop depth count 2008-07-29 13:36:09 +00:00
continue2.right hush: fix a bunch of obscure while/until/continue bugs 2009-04-06 18:08:35 +00:00
continue2.tests make hush-misc/*.tests executable 2009-04-06 18:10:20 +00:00
continue3.right hush: fix a bunch of obscure while/until/continue bugs 2009-04-06 18:08:35 +00:00
continue3.tests make hush-misc/*.tests executable 2009-04-06 18:10:20 +00:00
control_char1.right hush: fix raw ^C handlisg in single-quoted strings 2018-01-13 19:14:27 +01:00
control_char1.tests hush: fix raw ^C handlisg in single-quoted strings 2018-01-13 19:14:27 +01:00
control_char2.right hush: fix handling of ^C in eval 2018-01-11 13:17:30 +01:00
control_char2.tests hush: fix handling of ^C in eval 2018-01-11 13:17:30 +01:00
echo_write_error.right echo: do not retry on write errors 2011-02-07 02:03:51 +01:00
echo_write_error.tests echo: do not retry on write errors 2011-02-07 02:03:51 +01:00
empty_args.right hush: fix handling of empty arguments 2009-10-18 11:46:35 +02:00
empty_args.tests hush: fix handling of empty arguments 2009-10-18 11:46:35 +02:00
empty_for.right hush: fix "for a in; do echo 'I should never run'; done" bug 2008-06-17 12:09:21 +00:00
empty_for.tests hush: fix "for a in; do echo 'I should never run'; done" bug 2008-06-17 12:09:21 +00:00
empty_for1.right hush: fix another case where empty "for" wasn't setting exitcode to 0 2018-07-28 12:42:08 +02:00
empty_for1.tests hush: fix another case where empty "for" wasn't setting exitcode to 0 2018-07-28 12:42:08 +02:00
empty_for2.right hush: support "for v; do ... done" syntax (implied 'in "$@"') 2008-07-05 20:29:59 +00:00
empty_for2.tests hush: support "for v; do ... done" syntax (implied 'in "$@"') 2008-07-05 20:29:59 +00:00
env_and_func.right hush: fix bug where in "var=val func" var's value is not visible in func 2009-05-04 00:14:30 +02:00
env_and_func.tests ash: eval: Variable assignments on functions are no longer persistent 2018-08-05 11:14:11 +02:00
errexit1.right hush: add support for "set -e" 2017-07-14 13:36:48 +02:00
errexit1.tests hush: add support for "set -e" 2017-07-14 13:36:48 +02:00
eval1.right ash: [EVAL] Make eval with empty arguments return 0 2016-09-29 00:30:31 +02:00
eval1.tests ash: [EVAL] Make eval with empty arguments return 0 2016-09-29 00:30:31 +02:00
eval2.right hush: fix 'eval ""' handling 2016-09-29 01:44:17 +02:00
eval2.tests hush: fix 'eval ""' handling 2016-09-29 01:44:17 +02:00
exec.right add tests for basic fd open/close/dupe 2009-04-06 12:36:10 +00:00
exec.tests hush: heredoc support, based on patch by Mike Frysinger (vapier AT gentoo.org) 2009-04-07 02:29:51 +00:00
exit1.right hush: fix EXIT trap recursion case; check redirection failures 2009-04-09 13:43:11 +00:00
exit1.tests hush: fix EXIT trap recursion case; check redirection failures 2009-04-09 13:43:11 +00:00
exitcode_EACCES.right sh testsuite: add tests for exitcode on failure to exec 2016-10-03 00:55:34 +02:00
exitcode_EACCES.tests sh testsuite: add tests for exitcode on failure to exec 2016-10-03 00:55:34 +02:00
exitcode_ENOENT.right sh testsuite: add tests for exitcode on failure to exec 2016-10-03 00:55:34 +02:00
exitcode_ENOENT.tests sh testsuite: add tests for exitcode on failure to exec 2016-10-03 00:55:34 +02:00
exitcode1.right ash: eval: Return status in eval functions 2016-09-28 19:41:57 +02:00
exitcode1.tests ash: eval: Return status in eval functions 2016-09-28 19:41:57 +02:00
exitcode2.right ash: fix error code regression 2017-01-03 11:18:23 +01:00
exitcode2.tests ash: fix error code regression 2017-01-03 11:18:23 +01:00
export-n.right hush: export -n support 2009-04-20 22:04:21 +00:00
export-n.tests hush: export -n support 2009-04-20 22:04:21 +00:00
export.right hush: fix handling of } which is not a closing one in { cmd; } 2009-04-19 13:57:51 +00:00
export.tests hush: fix some TODOs. TODO in export builting: +250 bytes. 2009-04-10 13:49:10 +00:00
for_with_bslashes.right hush: fix raw ^C handlisg in single-quoted strings 2018-01-13 19:14:27 +01:00
for_with_bslashes.tests hush: fix raw ^C handlisg in single-quoted strings 2018-01-13 19:14:27 +01:00
for_with_keywords.right hush: support "for if in do done then; do echo $if; done" case 2008-07-06 10:01:13 +00:00
for_with_keywords.tests hush: support "for if in do done then; do echo $if; done" case 2008-07-06 10:01:13 +00:00
for.right hush: copy for.tests from ash testsuite 2015-10-29 22:37:25 +01:00
for.tests hush: copy for.tests from ash testsuite 2015-10-29 22:37:25 +01:00
func_args1.right hush: add two testcases 2009-04-20 10:52:31 +00:00
func_args1.tests hush-misc/func_args1.tests: remove "UNFIXED BUG", it does not fail 2015-11-04 14:50:19 +01:00
func_local1.right hush: add support for local builtin 2009-06-03 12:47:26 +02:00
func_local1.tests hush: add support for local builtin 2009-06-03 12:47:26 +02:00
func_local2.right hush: add support for local builtin 2009-06-03 12:47:26 +02:00
func_local2.tests hush: add support for local builtin 2009-06-03 12:47:26 +02:00
func_prio_over_builtins.right hush: functions have priority over builtins (!) 2017-07-31 05:27:09 +02:00
func_prio_over_builtins.tests hush: functions have priority over builtins (!) 2017-07-31 05:27:09 +02:00
func_return1.right hush: fix "true | func_with_return" not allowing return. 2017-07-31 18:02:28 +02:00
func_return1.tests hush: fix "true | func_with_return" not allowing return. 2017-07-31 18:02:28 +02:00
func_return2.right hush: fix "true | func_with_return" not allowing return. 2017-07-31 18:02:28 +02:00
func_return2.tests hush: fix "true | func_with_return" not allowing return. 2017-07-31 18:02:28 +02:00
func1.right hush: add function tests 2009-04-10 23:23:41 +00:00
func1.tests hush: add function tests 2009-04-10 23:23:41 +00:00
func2.right hush: add function tests 2009-04-10 23:23:41 +00:00
func2.tests hush: add function tests 2009-04-10 23:23:41 +00:00
func3.right hush: return builtin by Bayram Kurumahmut (kbayram AT ubicom.com) 2009-04-17 23:44:18 +00:00
func3.tests hush: return builtin by Bayram Kurumahmut (kbayram AT ubicom.com) 2009-04-17 23:44:18 +00:00
func4.right hush: nommu fix for function passing 2009-04-26 20:06:14 +00:00
func4.tests whitespace fixes 2010-01-25 13:39:24 +01:00
func5.right hush_test: test for subshell function syntax 2009-05-21 18:35:08 -04:00
func5.tests hush: support "f() (cmd)" functions 2018-04-03 14:56:52 +02:00
group_in_braces.right hush: allow { cmd } to not be terminated by semicolon in some cases 2016-11-04 18:46:14 +01:00
group_in_braces.tests hush: allow { cmd } to not be terminated by semicolon in some cases 2016-11-04 18:46:14 +01:00
if_false_exitcode.right hush: fix "if false; then...fi" exitcode; 2009-04-06 18:40:31 +00:00
if_false_exitcode.tests hush: fix "if false; then...fi" exitcode; 2009-04-06 18:40:31 +00:00
last_amp.right hush testsuite: add many tests from ash testsuite 2016-10-02 17:39:31 +02:00
last_amp.tests hush testsuite: add many tests from ash testsuite 2016-10-02 17:39:31 +02:00
local1.right hush testsuite: add many tests from ash testsuite 2016-10-02 17:39:31 +02:00
local1.tests hush testsuite: add many tests from ash testsuite 2016-10-02 17:39:31 +02:00
nommu1.right hush: fix \<newline> handling on NOMMU 2009-08-12 19:47:44 +02:00
nommu1.tests hush: fix \<newline> handling on NOMMU 2009-08-12 19:47:44 +02:00
nommu2.right hush: two NOMMU fixes for bugs 877 and 883 2010-01-12 13:45:45 +01:00
nommu2.tests hush: two NOMMU fixes for bugs 877 and 883 2010-01-12 13:45:45 +01:00
nommu3.right hush: fix a nommu bug where a part of function body is lost if run in a pipe 2015-09-04 06:22:10 +02:00
nommu3.tests typo fix 2015-10-13 01:49:06 +02:00
nulltick1.right hush testsuite: add many tests from ash testsuite 2016-10-02 17:39:31 +02:00
nulltick1.tests hush testsuite: add many tests from ash testsuite 2016-10-02 17:39:31 +02:00
opts1.right hush: do not process options after non-option args 2009-08-20 03:38:58 +02:00
opts1.tests hush: do not process options after non-option args 2009-08-20 03:38:58 +02:00
pid.right hush: fix $$ handling 2008-06-17 12:28:44 +00:00
pid.tests hush: fix $$ handling 2008-06-17 12:28:44 +00:00
pipefail.right hush: add support for "set -o pipefail" 2010-11-14 02:01:50 +01:00
pipefail.tests hush: add support for "set -o pipefail" 2010-11-14 02:01:50 +01:00
read.right hush: fix read builtin to not read ahead past eol and to not use 2007-06-13 06:47:47 +00:00
read.tests hush: fix read builtin to not read ahead past eol and to not use 2007-06-13 06:47:47 +00:00
return1.right hush: fix a case where return in sourced file has no effect 2011-03-24 02:50:03 +01:00
return1.tests hush: fix a case where return in sourced file has no effect 2011-03-24 02:50:03 +01:00
shift.right hush: improve 2 testsuite tests 2007-05-24 13:22:01 +00:00
shift.tests hush: improve 2 testsuite tests 2007-05-24 13:22:01 +00:00
shift1.right hush: Print error messages on shift -1 2017-07-06 20:12:44 +02:00
shift1.tests hush: Print error messages on shift -1 2017-07-06 20:12:44 +02:00
sig_exitcode.right hush: fix exitcodes of killed processes 2010-01-04 11:37:09 +01:00
sig_exitcode.tests hush: fix exitcodes of killed processes 2010-01-04 11:37:09 +01:00
source_argv_and_shift.right hush: fix a bug in argv restoration after sourcing a file 2017-01-09 08:13:21 +01:00
source_argv_and_shift.tests hush: fix a bug in argv restoration after sourcing a file 2017-01-09 08:13:21 +01:00
source1.right sh testsuite: sync ash-misc/source* and hush-misc/source* 2016-10-02 18:23:14 +02:00
source1.tests sh testsuite: sync ash-misc/source* and hush-misc/source* 2016-10-02 18:23:14 +02:00
source2.right sh testsuite: sync ash-misc/source* and hush-misc/source* 2016-10-02 18:23:14 +02:00
source2.tests sh testsuite: sync ash-misc/source* and hush-misc/source* 2016-10-02 18:23:14 +02:00
source3.right hush: fix ". EMPTY_LINE" not setting $? to 0 2016-09-29 01:27:09 +02:00
source3.tests hush: fix ". EMPTY_LINE" not setting $? to 0 2016-09-29 01:27:09 +02:00
source4.right sh testsuite: sync ash-misc/source* and hush-misc/source* 2016-10-02 18:23:14 +02:00
source4.tests sh testsuite: sync ash-misc/source* and hush-misc/source* 2016-10-02 18:23:14 +02:00
source5.right sh testsuite: sync ash-misc/source* and hush-misc/source* 2016-10-02 18:23:14 +02:00
source5.tests sh testsuite: sync ash-misc/source* and hush-misc/source* 2016-10-02 18:23:14 +02:00
syntax_err_negate.right hush: improve parse_stream: does not require parsing context struct; 2009-04-03 16:49:04 +00:00
syntax_err_negate.tests hush: support "! cmd | cmd" negation 2008-06-14 11:00:17 +00:00
syntax_err.right hush: finally make cmd safe on NOMMU 2009-04-03 22:31:18 +00:00
syntax_err.tests hush: improve 2 testsuite tests 2007-05-24 13:22:01 +00:00
tickquote1.right hush: add tickquote1.tests from ash testsuite 2017-07-06 18:31:47 +02:00
tickquote1.tests hush: add tickquote1.tests from ash testsuite 2017-07-06 18:31:47 +02:00
unicode1.right hush: make ${#var} unicode-aware 2014-08-13 09:57:44 +02:00
unicode1.tests Spelling fixes in comments, documentation, tests and examples 2017-04-17 16:13:32 +02:00
until1.right hush: fix a bunch of obscure while/until/continue bugs 2009-04-06 18:08:35 +00:00
until1.tests make hush-misc/*.tests executable 2009-04-06 18:10:20 +00:00
wait1.right hush: fix "wait PID" 2016-10-28 21:59:09 +02:00
wait1.tests hush: fix "wait PID" 2016-10-28 21:59:09 +02:00
wait2.right hush: fix "wait PID" 2016-10-28 21:59:09 +02:00
wait2.tests hush: fix "wait PID" 2016-10-28 21:59:09 +02:00
wait3.right hush: fix "wait PID" 2016-10-28 21:59:09 +02:00
wait3.tests hush: fix "wait PID" 2016-10-28 21:59:09 +02:00
wait4.right hush: rework "wait %jobspec" to work in non-interactive shells too 2016-11-08 00:59:29 +01:00
wait4.tests hush: rework "wait %jobspec" to work in non-interactive shells too 2016-11-08 00:59:29 +01:00
wait5.right hush: rework "wait %jobspec" to work in non-interactive shells too 2016-11-08 00:59:29 +01:00
wait5.tests hush: rework "wait %jobspec" to work in non-interactive shells too 2016-11-08 00:59:29 +01:00
wait6.right hush: fix "(sleep 1; exit 3) & sleep 2; echo $?; wait $!; echo $?" 2017-07-07 22:56:02 +02:00
wait6.tests hush: fix "(sleep 1; exit 3) & sleep 2; echo $?; wait $!; echo $?" 2017-07-07 22:56:02 +02:00
while_in_subshell.right hush: fix a bug where we were requiring semicolon here: (cmd;) 2008-06-14 17:13:20 +00:00
while_in_subshell.tests hush: fix a bug where we were requiring semicolon here: (cmd;) 2008-06-14 17:13:20 +00:00
while1.right hush: fix "while false; ..." exitcode; add testsuites 2008-07-28 23:17:31 +00:00
while1.tests hush: fix "while false; ..." exitcode; add testsuites 2008-07-28 23:17:31 +00:00
while2.right hush: fix a bunch of obscure while/until/continue bugs 2009-04-06 18:08:35 +00:00
while2.tests make hush-misc/*.tests executable 2009-04-06 18:10:20 +00:00
while3.right hush: fix a corner case of empty "do \n done" structure 2011-05-31 17:35:45 +02:00
while3.tests hush: fix a corner case of empty "do \n done" structure 2011-05-31 17:35:45 +02:00
while4.right hush: fix for "while false && true; do echo BUG; break; done". closes 6170 2013-04-07 18:16:58 +02:00
while4.tests hush: fix for "while false && true; do echo BUG; break; done". closes 6170 2013-04-07 18:16:58 +02:00