On 8/19/19 11:47 AM, Thorsten Glaser wrote: > Package: bash > Version: 5.0-4 > Severity: critical > Justification: breaks unrelated software >
> The expected output is: > > dbc_mysql_createdb: _dbc_nodb(1)= # initially not set / empty > dbc_mysql_exec_command: _dbc_nodb=yes # MUST be visible inside the function > inner: 0 or 1 # MAY be exported, does not need to > dbc_mysql_createdb: _dbc_nodb(2)=[yes] # MAY be visible afterwards, > optional > after: 0 or 1 # if visible afterwards MAY be exported > dbc_mysql_createdb:0 > > POSIX reference: > http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_09_01 > specifically: > > * 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) This behavior hasn't changed substantially since bash-4.4: it still implements the previous version of the Posix standard, which says that assignment statements preceding functions are supposed to be treated like special builtins. $ cat x15b # test whether or not temporary environment assignments are exported # in posix mode #set -o posix showfoo() { printf %s "foo=${foo-<unset>}" echo -n ' environment foo=' printenv foo || echo } unset foo showfoo foo=foo showfoo showfoo $ ./bash -o posix ./x15b foo=<unset> environment foo= foo=foo environment foo=foo foo=foo environment foo=foo $ ../bash-5.0-patched/bash -o posix ./x15b foo=<unset> environment foo= foo=foo environment foo=foo foo=foo environment foo=foo $ ../bash-4.4-patched/bash -o posix ./x15b foo=<unset> environment foo= foo=foo environment foo=foo foo=foo environment foo=foo (The first test uses the current development version.) I don't see substantial differences when I interpose another function in between and call showfoo from that function with a preceding assignment statement. There is a problem with bash-5.0 when the variable is declared local in the interposed function, and I need to fix that, but that's not a posix issue because posix doesn't have anything to say about local variables. So thanks for the report, and I'll look at the local variable issue. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/