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

Path csiph.com!feeder.erje.net!2.us.feeder.erje.net!weretis.net!feeder6.news.weretis.net!nntp.club.cc.cmu.edu!micro-heart-of-gold.mit.edu!bloom-beacon.mit.edu!bloom-beacon.mit.edu!171.64.64.130.MISMATCH!usenet.stanford.edu!not-for-mail
From Martijn Dekker <martijn@inlv.org>
Newsgroups gnu.bash.bug
Subject [BUG] persistently assigned variable cannot be unexported in POSIX mode
Date Thu, 26 Apr 2018 04:51:53 +0200
Lines 33
Approved bug-bash@gnu.org
Message-ID <mailman.12985.1524711127.27995.bug-bash@gnu.org> (permalink)
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1524711128 14130 208.118.235.17 (26 Apr 2018 02:52:08 GMT)
X-Complaints-To action@cs.stanford.edu
To "bug-bash@gnu.org" <bug-bash@gnu.org>
Envelope-to bug-bash@gnu.org
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:52.0) Gecko/20100101 Thunderbird/52.7.0
Content-Language en-GB
X-detected-operating-system by eggs.gnu.org: GNU/Linux 3.x [fuzzy]
X-Received-From 37.59.109.123
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14055

Show key headers only | 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