If a local array variable shadows an exported variable from a higher
scope, that variable is usually removed from the export environment.
However, if an external command is executed between the last time an
exported variable was modified and the local array is created, the
existing variable remains in the environment until the next time that
an exported variable is modified.
f() {
local -a x=()
printenv x || echo N1
export y=Y
printenv x || echo N2
}
$ export x=X; f
N1
N2
$ export x=X; $(:); f
X
N2
The example uses a command substitution, but `env true' works too, as
long as neither LINES nor COLUMNS is exported, or checkwinsize is off.