Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14055 > unrolled thread

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

Started byMartijn Dekker <martijn@inlv.org>
First post2018-04-26 04:51 +0200
Last post2018-04-26 04:51 +0200
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug


Contents

  [BUG] persistently assigned variable cannot be unexported in POSIX mode Martijn Dekker <martijn@inlv.org> - 2018-04-26 04:51 +0200

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

FromMartijn Dekker <martijn@inlv.org>
Date2018-04-26 04:51 +0200
Subject[BUG] persistently assigned variable cannot be unexported in POSIX mode
Message-ID<mailman.12985.1524711127.27995.bug-bash@gnu.org>
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.

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web