bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[BUG] persistently assigned variable cannot be unexported in POSIX mode


From: Martijn Dekker
Subject: [BUG] persistently assigned variable cannot be unexported in POSIX mode
Date: Thu, 26 Apr 2018 04:51:53 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

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

[Prev in Thread] Current Thread [Next in Thread]