On Sunday, May 04, 2014 01:22:02 AM Arfrever Frehtes Taifersar Arahesis wrote:
> 'local -x VARIABLE' (without assignment of value) does not clear
> variable for subprocesses.  It is regression in bash 4.3.
>
> Behavior of 'local VARIABLE' without -x option also changed, but I am
> not sure what should be correct behavior in that case.
>
> bash 4.2.47:
>
> $ export VAR1=abc VAR2=abc
> $ f() { local VAR1; local -x VAR2; bash -c 'declare -p VAR{1,2}'; }
> $ f
> bash: line 0: declare: VAR1: not found
> bash: line 0: declare: VAR2: not found
>
> bash 4.3.11:
>
> $ export VAR1=abc VAR2=abc
> $ f() { local VAR1; local -x VAR2; bash -c 'declare -p VAR{1,2}'; }
> $ f
> declare -x VAR1="abc"
> declare -x VAR2="abc"
>
> --
> Arfrever Frehtes Taifersar Arahesis

This is pretty ambiguous territory. One thing that did change in 4.3 is
that you can now unexport a variable that was exported to a function
through an assignment during the call via `typeset +x`, but I believe
that's unrelated to a separate `export`.

I reran one of my old tests:
https://gist.github.com/ormaaj/04923e11e8bdc27688ad#file-output

As you can see there isn't much rhyme or reason to the results, and
these tests take into account all the other differences that don't have
to do with exporting.

Test 1 exports a global then localizes it. Test 2 exports a local and
tests a local from a child scope. Test 3 tests exported namerefs.

--
Dan Douglas

Reply via email to