bug-bash
[Top][All Lists]
Advanced

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

Possible bug in 'unset' builtin


From: Dreamcat4
Subject: Possible bug in 'unset' builtin
Date: Fri, 1 May 2015 19:26:23 +0100

Hello.
If you unset a function, then a variable argument (argv) specified after that function will not be unset.

To reproduce:

[19:20] < koala_man> # var1=foo; funcA() { echo foo; }; var2=bar; unset var1 funcA var2; declare -p var1 var2;


[19:24] < dreamcat4^> echo "$BASH_VERSION"
[19:24] < dreamcat4^> 4.3.30(1)-release
[19:25] < dreamcat4^> ubuntu-14.10


Kind Regards
Dreamat4


#bash IRCNet channel log:

[19:18] < koala_man> dreamcat4^: do you have a self contained test case?
[19:18] < dreamcat4^> mute: sorry, i re-organised it a bit. try: unset var1 funcA var2 funcB
[19:19] < dreamcat4^> and var2 will NOT be unset (in shell script)
[19:19] < dreamcat4^> koala_man: no
[19:19] ~~~LBV_User [~leonardo@177.18.49.1] has joined #bash
[19:20] < koala_man> # var1=foo; funcA() { echo foo; }; var2=bar; unset var1 funcA var2; declare -p var1 var2;
[19:20] < shbot> koala_man: bash: declare: var1: not found
[19:20] < shbot> koala_man: declare -- var2="bar"
[19:20] < koala_man> indeed
[19:20] < dualbus> unset them separately
[19:20] < dualbus> unset var1 var2; unset -f funcA funcB
[19:20] < koala_man> dualbus: why?
[19:20] < dreamcat4^> thanks koala_man
[19:20] ~~~Nick_ZWG [~nmcspadde@unaffiliated/nmcspadden] has joined #bash
[19:21] < koala_man> apparently, any variable after a function will not be unset
[19:21] < dualbus> koala_man: as a work around for the bug that I'm going to report without crediting dreamcat4^ :-P
[19:21] < dreamcat4^> koala_man: you example reproduces this behaviour exactly.
[19:22] ~~~narendraj9 [~narendraj@106.78.113.154] has quit [Quit: WeeChat 1.1.1]
[19:22] < dualbus> nah, just kidding. dreamcat4^ report it to bug-bash@gnu.org
[19:22] < dualbus> (use koala_man's short version as an example)
[19:22] < dreamcat4^> dualbus: ok. i'll send an email with koala_man's example.
[19:22] < dualbus> but now, since we don't know what bash versions are broken, you'll have to unset them separately
[19:22] < mute> 42# var1=foo; funcA() { echo foo; }; var2=bar; unset var1 funcA var2; declare -p var1 var2;
[19:22] < shbot> mute: bash: declare: var1: not found
[19:22] < shbot> mute: bash: declare: var2: not found
[19:23] < mute> that's why
[19:23] < mute> i've 4.2 here
[19:23] < koala_man> # echo "$BASH_VERSION"
[19:23] < shbot> koala_man: 4.3.33(2)-release
[19:23] < mute> +# var1=foo; funcA() { echo foo; }; var2=bar; unset var1 funcA var2; declare -p var1 var2;
[19:23] < shbot> mute: bash: declare: var1: not found
[19:23] < shbot> mute: declare -- var2="bar"
[19:23] < dualbus> ah, nice, so yet another regression
[19:24] < dualbus> for every fix that Chet does, he introduces like 2 bugs. Nice way of keeping himself busy
[19:24] < dreamcat4^> echo "$BASH_VERSION"
[19:24] < dreamcat4^> 4.3.30(1)-release
[19:25] < dreamcat4^> ubuntu-14.10
[19:25] ~~~rismoney1 [~rismoney1@74.120.84.62] has joined #bash


reply via email to

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