POSIX allows assignments preceding special builtins such as ':', 'set', etc. not only to persist but also to be persistently exported. I think that exporting behaviour is inherently broken and it's unfortunate that bash does this in POSIX mode, as it's merely allowed and not actually mandated, but anyway...

What I'm reporting here is a bug I discovered with unexporting a variable that is so exported while bash is in POSIX mode. It cannot be unexported using 'typeset +x' if you try to do that in a shell function.

This works:

$ bash -o posix -c 'foo=abc : ; typeset +x foo; env|grep ^foo='
(no output, as expected: no longer exported)

But this doesn't:

$ bash -o posix -c 'fn() { foo=abc : ; typeset +x foo; env|grep ^foo=; }; fn'
foo=abc

Bug confirmed on all bash versions down to 2.05b.

I've also succeeded in making 'unset -v' fail silently for a variable that is so exported, but I've so far been unable to track down a specific reproducer that is simple enough to post here. It occurred as a failure in the modernish regression test suite, which is extensive. Chet, let me know if you want a reproducer for that and I'll email you a tarball plus instructions. It seems likely that fixing the bug reported above would fix that one as well, though.

- M.

Reply via email to