[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: segfault w/ localvar_inherit and associative array insert
From: |
Grisha Levit |
Subject: |
Re: segfault w/ localvar_inherit and associative array insert |
Date: |
Mon, 6 Aug 2018 18:46:17 -0400 |
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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: segfault w/ localvar_inherit and associative array insert,
Grisha Levit <=