Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14457
| From | Grisha Levit <grishalevit@gmail.com> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: segfault w/ localvar_inherit and associative array insert |
| Date | 2018-08-06 18:46 -0400 |
| Message-ID | <mailman.4775.1533595593.1292.bug-bash@gnu.org> (permalink) |
| References | (1 earlier) <2e51ae31-5fb0-633b-6d7b-faab8df39585@case.edu> <CAMu=Brpvrg2GHwy8zs5hiWN_cReUupa=014JmfCNKMxaJws2Bw@mail.gmail.com> <54c2fc17-c47f-ed94-23a5-8f23f3c6cb87@case.edu> <CAMu=BrpQUf9U5qdAiojH6oGjAkUx_PPw-sZWdxcricpvsgkY2w@mail.gmail.com> <6ff6c1f7-1250-c484-b0ee-60c79dee46d0@case.edu> |
I don't know if this makes consistency easier or harder, but there is
currently code to handle `declare' with -[iluc] early [1]. As a result, a
combination of localvar_inherit and the use of one of those options when
declaring a local variable allows (correctly or not) for associative arrays
to inherit their previous value and have elements inserted at the same time:
$ declare -A A; A[X]=X
$ f() { local -u A+=([Y]=Y); declare -p A; }; f
declare -Au A=([X]="X" [Y]="Y" )
$ f() { local -u +u A+=([Y]=Y); declare -p A; }; f
declare -A A=([X]="X" [Y]="Y" )
$ f() { local A+=([Y]=Y); declare -p A; }; f
-bash: warning: A: cannot inherit value from incompatible type
[1]
https://git.savannah.gnu.org/cgit/bash.git/tree/subst.c?h=devel&id=057a9fbdb4d9ad01b000743fcea9918b80823afc#n11199
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: segfault w/ localvar_inherit and associative array insert Grisha Levit <grishalevit@gmail.com> - 2018-08-06 18:46 -0400
csiph-web