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


Groups > gnu.bash.bug > #14055

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

From Martijn Dekker <martijn@inlv.org>
Newsgroups gnu.bash.bug
Subject [BUG] persistently assigned variable cannot be unexported in POSIX mode
Date 2018-04-26 04:51 +0200
Message-ID <mailman.12985.1524711127.27995.bug-bash@gnu.org> (permalink)

Show all headers | View raw


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.

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web