Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14402 > unrolled thread
| Started by | Grisha Levit <grishalevit@gmail.com> |
|---|---|
| First post | 2018-07-26 15:15 -0400 |
| Last post | 2018-07-26 15:15 -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.
Re: segfault w/ localvar_inherit and associative array insert Grisha Levit <grishalevit@gmail.com> - 2018-07-26 15:15 -0400
| From | Grisha Levit <grishalevit@gmail.com> |
|---|---|
| Date | 2018-07-26 15:15 -0400 |
| Subject | Re: segfault w/ localvar_inherit and associative array insert |
| Message-ID | <mailman.4276.1532632548.1292.bug-bash@gnu.org> |
It seems that in general the array type is inherited just fine, there is an
issue only in the case that:
* the `A' attribute is inherited but not explicitly supplied
* we are creating the local variable with the `declare' command
(i.e. it is not already an existing local variable)
* we are performing a compound assignment/append operation in the
same declare command
For example, given:
shopt -s localvar_inherit
declare -A var=([X]=X)
These all work smoothly:
## no explicit `-A', no assignment in `declare':
f() { declare var; declare -p var; }; f
# declare -A var=([X]="X" )
f() { declare var; var=([Y]=Y); declare -p var; }; f
# declare -A var=([Y]="Y" )
f() { declare var; var+=([Y]=Y); declare -p var; }; f
# declare -A var=([X]="X" [Y]="Y" )
## explicit `-A', assignment in `declare':
f() { declare -A var=([Y]=Y); declare -p var; }; f
# declare -A var=([Y]="Y" )
f() { declare -A var+=([Y]=Y); declare -p var; }; f
# declare -A var=([X]="X" [Y]="Y" )
## non-compound assignment:
f() { declare var[Y]=Y; declare -p var; }; f
declare -A var=([X]="X" [Y]="Y" )
But here we have some issues:
## no explicit `-A', assignment in `declare':
f() { declare var=([Y]=Y); declare -p var; }; f
# Segmentation fault: 11
f() { declare var+=([Y]=Y); declare -p var; }; f
# Segmentation fault: 11
f() { declare var+=(); declare -p var; }; f
# declare -aA var=()
f() { declare var=(); declare -p var; }; f
declare -aA var=()
Back to top | Article view | gnu.bash.bug
csiph-web