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


Groups > gnu.bash.bug > #14457 > unrolled thread

Re: segfault w/ localvar_inherit and associative array insert

Started byGrisha Levit <grishalevit@gmail.com>
First post2018-08-06 18:46 -0400
Last post2018-08-06 18:46 -0400
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: segfault w/ localvar_inherit and associative array insert Grisha Levit <grishalevit@gmail.com> - 2018-08-06 18:46 -0400

#14457 — Re: segfault w/ localvar_inherit and associative array insert

FromGrisha Levit <grishalevit@gmail.com>
Date2018-08-06 18:46 -0400
SubjectRe: segfault w/ localvar_inherit and associative array insert
Message-ID<mailman.4775.1533595593.1292.bug-bash@gnu.org>
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

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web