Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #13775
| Path | csiph.com!feeder.erje.net!2.us.feeder.erje.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 | Greg Wooledge <wooledg@eeg.ccf.org> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: Unset array doesn't work |
| Date | Wed, 28 Feb 2018 15:00:51 -0500 |
| Lines | 57 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.9902.1519848059.27995.bug-bash@gnu.org> (permalink) |
| References | <ba594d01-b9c4-5cd8-9fa0-2f20fd1d2d07@case.edu> <21679c48-4064-5683-2d5f-91bfb76687d0@case.edu> <790ade74-690f-541c-9ab4-6359917442d0@case.edu> <a56e05b1-0b34-1cb2-6073-91c12f27e228@gmail.com> <a642644f-e475-6361-140e-5b47ab4e321c@case.edu> <755d61fa-d2bc-8855-bc30-4388aff40691@gmail.com> <9974.1519637469@jinx.noi.kre.to> <15717.1519764581@jinx.noi.kre.to> <24248.1519844400@jinx.noi.kre.to> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| X-Trace | usenet.stanford.edu 1519848060 32521 208.118.235.17 (28 Feb 2018 20:01:00 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| To | bug-bash@gnu.org |
| Envelope-to | bug-bash@gnu.org |
| Mail-Followup-To | bug-bash@gnu.org |
| Content-Disposition | inline |
| In-Reply-To | <24248.1519844400@jinx.noi.kre.to> |
| User-Agent | NeoMutt/20170113 (1.7.2) |
| X-detected-operating-system | by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] |
| X-Received-From | 139.137.100.1 |
| 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:13775 |
Show key headers only | View raw
I think most people will agree that unset is extremely surprising,
though they may point to different parts of it as the source of their
surprise.
8 years after Freddy Vulto's initial investigations, there are many
things I still don't understand. For example, consider this code
straight from his web site[1]:
=====================================================================
wooledg:~$ cat freddy
#!/bin/bash
a=0 b=0 c=0 d=0 e=0
_unset() { unset -v b c c d d d e; }
t1() {
local a=1 b=1 c=1 d=1
t2
}
t2() {
local a=2 b=2 c=2 d=2 e=2
_unset
echo a:$a b:$b c:$c d:$d e:$e
}
t1
wooledg:~$ ./freddy
a:2 b:1 c:0 d: e:0
=====================================================================
But if I make a tiny change to it (eliminating the _unset function which
*appears* to have no purpose), it has entirely different behavior:
=====================================================================
wooledg:~$ cat freddy2
#!/bin/bash
a=0 b=0 c=0 d=0 e=0
t1() {
local a=1 b=1 c=1 d=1
t2
}
t2() {
local a=2 b=2 c=2 d=2 e=2
unset -v b c c d d d e
echo a:$a b:$b c:$c d:$d e:$e
}
t1
wooledg:~$ ./freddy2
a:2 b: c: d: e:
=====================================================================
I don't understand the difference.
Does unset create some kind of "placeholder" in the current function
(but not in a caller)?
[1] http://fvue.nl/wiki/Bash:_Unset
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: Unset array doesn't work Greg Wooledge <wooledg@eeg.ccf.org> - 2018-02-28 15:00 -0500
csiph-web