busybox/shell/ash_test/ash-vars
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
..
empty.right ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
empty.tests ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
glob_and_vars.right ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
glob_and_vars.tests ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
param_expand_alt2.right ash: parser: Allow newlines within parameter substitution 2018-04-11 12:39:18 +02:00
param_expand_alt2.tests ash: parser: Allow newlines within parameter substitution 2018-04-11 12:39:18 +02:00
param_expand_alt.right shell: remove ${#+} tests, it is not a valid construct 2017-07-26 00:30:02 +02:00
param_expand_alt.tests shell: remove ${#+} tests, it is not a valid construct 2017-07-26 00:30:02 +02:00
param_expand_assign.right ash: update testsuite (we now error out on ${#=}) 2017-08-14 15:01:32 +02:00
param_expand_assign.tests ash: add a few tests from hush-vars/* 2017-07-25 14:55:05 +02:00
param_expand_bash_substring.right shell: echo ${?:0} was fixed sometime ago, enable it in tests 2018-01-13 19:28:19 +01:00
param_expand_bash_substring.tests shell: echo ${?:0} was fixed sometime ago, enable it in tests 2018-01-13 19:28:19 +01:00
param_expand_default.right ash: import param_expand_default.tests from hush 2017-07-25 15:25:07 +02:00
param_expand_default.tests ash: import param_expand_default.tests from hush 2017-07-25 15:25:07 +02:00
param_expand_indicate_error.right hush: treat ${#?} as "length of $?" 2017-07-25 15:18:57 +02:00
param_expand_indicate_error.tests hush: treat ${#?} as "length of $?" 2017-07-25 15:18:57 +02:00
param_expand_len1.right hush: fix ${##}, ${#?}, ${#!} handling 2017-07-26 00:07:27 +02:00
param_expand_len1.tests hush: fix ${##}, ${#?}, ${#!} handling 2017-07-26 00:07:27 +02:00
param_expand_len.right ash: [PARSER] Fix parsing of ${##1} 2016-10-26 15:56:53 +02:00
param_expand_len.tests ash: [PARSER] Fix parsing of ${##1} 2016-10-26 15:56:53 +02:00
param_glob.right ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
param_glob.tests ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
param_subshell.right ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
param_subshell.tests ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
readonly0.right ash: [VAR] Move unsetvar functionality into setvareq 2017-07-25 16:29:36 +02:00
readonly0.tests ash: suppress readonly1.tests false positive; add readonly0.tests 2017-07-21 13:37:25 +02:00
readonly1.right ash: suppress readonly1.tests false positive; add readonly0.tests 2017-07-21 13:37:25 +02:00
readonly1.tests ash: suppress readonly1.tests false positive; add readonly0.tests 2017-07-21 13:37:25 +02:00
star.right ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
star.tests ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
unset.right ash: [VAR] Move unsetvar functionality into setvareq 2017-07-25 16:29:36 +02:00
unset.tests ash: [VAR] Move unsetvar functionality into setvareq 2017-07-25 16:29:36 +02:00
var1.right sh testsuite: sync ash-vars/ and hush-vars/ 2016-10-02 18:17:15 +02:00
var1.tests sh testsuite: sync ash-vars/ and hush-vars/ 2016-10-02 18:17:15 +02:00
var2.right sh testsuite: sync ash-vars/ and hush-vars/ 2016-10-02 18:17:15 +02:00
var2.tests sh testsuite: sync ash-vars/ and hush-vars/ 2016-10-02 18:17:15 +02:00
var3.right ash: fix handling of duplicate "local" 2015-04-18 19:36:38 +02:00
var3.tests ash: fix handling of duplicate "local" 2015-04-18 19:36:38 +02:00
var4.right sh testsuite: sync ash-vars/ and hush-vars/ 2016-10-02 18:17:15 +02:00
var4.tests sh testsuite: sync ash-vars/ and hush-vars/ 2016-10-02 18:17:15 +02:00
var5.right sh testsuite: sync ash-vars/ and hush-vars/ 2016-10-02 18:17:15 +02:00
var5.tests sh testsuite: sync ash-vars/ and hush-vars/ 2016-10-02 18:17:15 +02:00
var_bash1.right
var_bash1.tests
var_bash1a.right ash: fix handling of ${VAR: -2} 2016-07-25 03:56:00 +02:00
var_bash1a.tests typo fix 2017-07-06 19:50:42 +02:00
var_bash1b.right ash: more general format ${var:EXPR:EXPR} 2017-07-17 17:49:11 +02:00
var_bash1b.tests ash: more general format ${var:EXPR:EXPR} 2017-07-17 17:49:11 +02:00
var_bash2.right
var_bash2.tests
var_bash3.right ash: parser: Add syntax stack for recursive parsing 2018-04-02 13:15:37 +02:00
var_bash3.tests hush: add support for ${var/pattern/repl}, conditional on bash compat 2010-09-05 14:47:58 +02:00
var_bash4.right ash: parser: Add syntax stack for recursive parsing 2018-04-02 13:15:37 +02:00
var_bash4.tests ash testsuite: update some of variable tests with newer versions from hush 2016-10-02 18:08:04 +02:00
var_bash5.right ash testsuite: update some of variable tests with newer versions from hush 2016-10-02 18:08:04 +02:00
var_bash5.tests ash testsuite: update some of variable tests with newer versions from hush 2016-10-02 18:08:04 +02:00
var_bash6.right ash: parser: Add syntax stack for recursive parsing 2018-04-02 13:15:37 +02:00
var_bash6.tests ash: parser: Add syntax stack for recursive parsing 2018-04-02 13:15:37 +02:00
var_bash7.right ash: parser: Add syntax stack for recursive parsing 2018-04-02 13:15:37 +02:00
var_bash7.tests ash: parser: Add syntax stack for recursive parsing 2018-04-02 13:15:37 +02:00
var_bash_pattern_starting_with_slash.right ash,hush: properly handle ${v//pattern/repl} if pattern starts with / 2018-08-04 22:25:28 +02:00
var_bash_pattern_starting_with_slash.tests ash,hush: properly handle ${v//pattern/repl} if pattern starts with / 2018-08-04 22:25:28 +02:00
var_bash_repl_empty_pattern.right ash testsuite: add two hush tests from last commit 2018-01-25 14:09:06 +01:00
var_bash_repl_empty_pattern.tests ash testsuite: add two hush tests from last commit 2018-01-25 14:09:06 +01:00
var_bash_repl_empty_var.right ash testsuite: add two hush tests from last commit 2018-01-25 14:09:06 +01:00
var_bash_repl_empty_var.tests ash testsuite: add two hush tests from last commit 2018-01-25 14:09:06 +01:00
var_expand_in_assign.right ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
var_expand_in_assign.tests ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
var_expand_in_redir.right ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
var_expand_in_redir.tests ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
var_expand_on_ifs.right ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
var_expand_on_ifs.tests ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
var_in_pipes.right ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
var_in_pipes.tests ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
var_leak.right ash: eval: Variable assignments on functions are no longer persistent 2018-08-05 11:14:11 +02:00
var_leak.tests ash: eval: Variable assignments on functions are no longer persistent 2018-08-05 11:14:11 +02:00
var_leaks.right ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
var_leaks.tests ash testsuite: add most of hust tests which pass for ash 2016-10-03 00:06:55 +02:00
var_LINENO1.right shells: fix var_LINENO1.tests false positive, add it to ash tests too 2018-03-31 20:31:13 +02:00
var_LINENO1.tests shells: fix var_LINENO1.tests false positive, add it to ash tests too 2018-03-31 20:31:13 +02:00
var_posix1.right ash testsuite: update some of variable tests with newer versions from hush 2016-10-02 18:08:04 +02:00
var_posix1.tests ash testsuite: update some of variable tests with newer versions from hush 2016-10-02 18:08:04 +02:00
var_serial.right hush: rework input char buffering to allow more than one-deep peek 2016-09-29 16:59:06 +02:00
var_serial.tests hush: rework input char buffering to allow more than one-deep peek 2016-09-29 16:59:06 +02:00
var_subst_in_for.right hush: rework input char buffering to allow more than one-deep peek 2016-09-29 16:59:06 +02:00
var_subst_in_for.tests hush: rework input char buffering to allow more than one-deep peek 2016-09-29 16:59:06 +02:00
var_unbackslash1.right ash: fix arithmetic closing )) split by backslash-newline 2016-09-29 17:58:58 +02:00
var_unbackslash1.tests shell testsuite: add trailing newline to var_unbackslash1.tests 2016-09-29 20:02:53 +02:00
var_unbackslash.right hush: rework input char buffering to allow more than one-deep peek 2016-09-29 16:59:06 +02:00
var_unbackslash.tests hush: rework input char buffering to allow more than one-deep peek 2016-09-29 16:59:06 +02:00
var_wordsplit_ifs1.right ash: expand: Fixed "$@" expansion when EXP_FULL is false 2016-10-02 02:46:56 +02:00
var_wordsplit_ifs1.tests ash: expand: Fixed "$@" expansion when EXP_FULL is false 2016-10-02 02:46:56 +02:00
var_wordsplit_ifs2.right ash: [EXPAND] Do not split quoted VSLENGTH and VSTRIM 2016-10-01 20:55:02 +02:00
var_wordsplit_ifs2.tests ash: [EXPAND] Do not split quoted VSLENGTH and VSTRIM 2016-10-01 20:55:02 +02:00
var_wordsplit_ifs3.right ash: [EXPAND] Do not split quoted VSLENGTH and VSTRIM 2016-10-01 20:55:02 +02:00
var_wordsplit_ifs3.tests ash: [EXPAND] Do not split quoted VSLENGTH and VSTRIM 2016-10-01 20:55:02 +02:00
var_wordsplit_ifs4.right hush: IFS fixes 2018-04-11 16:02:58 +02:00
var_wordsplit_ifs4.tests hush: IFS fixes 2018-04-11 16:02:58 +02:00
var-do-not-collapse-arithmetic-expansion-at-parse-time.right ash: remove arithmetic expansion collapsing at parse time 2015-05-18 09:56:16 +02:00
var-do-not-collapse-arithmetic-expansion-at-parse-time.tests ash: remove arithmetic expansion collapsing at parse time 2015-05-18 09:56:16 +02:00
var-do-not-expand-tilde-in-parameter-expansion-in-quotes.right ash: do not expand tilde in parameter expansion within quotes 2015-05-18 09:53:26 +02:00
var-do-not-expand-tilde-in-parameter-expansion-in-quotes.tests ash: do not expand tilde in parameter expansion within quotes 2015-05-18 09:53:26 +02:00
var-do-not-quote-backslashes-in-parameter-expansions-outside-quotes.right ash: move parse-time quote flag detection to run-time 2015-05-18 09:57:51 +02:00
var-do-not-quote-backslashes-in-parameter-expansions-outside-quotes.tests ash: move parse-time quote flag detection to run-time 2015-05-18 09:57:51 +02:00
var-expand-tilde-in-parameter-expansion.right ash: perform tilde expansion in all parameter expansion words 2015-05-18 09:51:35 +02:00
var-expand-tilde-in-parameter-expansion.tests ash: perform tilde expansion in all parameter expansion words 2015-05-18 09:51:35 +02:00
var-pattern-replacement-in-parameter-expansion-1.right testsuite: add some tests for ash 2015-05-18 10:13:21 +02:00
var-pattern-replacement-in-parameter-expansion-1.tests testsuite: add some tests for ash 2015-05-18 10:13:21 +02:00
var-pattern-replacement-in-parameter-expansion-2.right testsuite: add some tests for ash 2015-05-18 10:13:21 +02:00
var-pattern-replacement-in-parameter-expansion-2.tests testsuite: add some tests for ash 2015-05-18 10:13:21 +02:00
var-pattern-replacement-in-parameter-expansion-3.right testsuite: add some tests for ash 2015-05-18 10:13:21 +02:00
var-pattern-replacement-in-parameter-expansion-3.tests testsuite: add some tests for ash 2015-05-18 10:13:21 +02:00
var-pattern-replacement-in-parameter-expansion-4.right testsuite: add some tests for ash 2015-05-18 10:13:21 +02:00
var-pattern-replacement-in-parameter-expansion-4.tests testsuite: add some tests for ash 2015-05-18 10:13:21 +02:00
var-pattern-replacement-in-parameter-expansion-5.right testsuite: add some tests for ash 2015-05-18 10:13:21 +02:00
var-pattern-replacement-in-parameter-expansion-5.tests testsuite: add some tests for ash 2015-05-18 10:13:21 +02:00
var-runtime-quote-detection.right ash: move parse-time quote flag detection to run-time 2015-05-18 09:57:51 +02:00
var-runtime-quote-detection.tests ash: move parse-time quote flag detection to run-time 2015-05-18 09:57:51 +02:00
var-utf8-length.right ash: fix corruption of ${#var} if $var contains UTF-8 characters 2016-03-22 18:19:29 -04:00
var-utf8-length.tests hush: "adopt" ash var-utf8-length.tests 2017-07-06 19:29:23 +02:00