Re: segfault w/ localvar_inherit and associative array insert

2018-08-06 Thread Grisha Levit
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 inh

Re: segfault w/ localvar_inherit and associative array insert

2018-07-31 Thread Chet Ramey
On 7/29/18 10:26 PM, Grisha Levit wrote: > Though my motivation in reporting this was to point out the segfault, I'm a > bit confused by why compound assignment should be an error here. > >> Bash is consistent in defaulting to indexed array variables when you don't >> specify -A and assign a value

Re: segfault w/ localvar_inherit and associative array insert

2018-07-30 Thread Chet Ramey
On 7/25/18 5:37 PM, Grisha Levit wrote: > shopt -s localvar_inherit > declare -A var > f() { declare var+=([0]=X); }; f This will generate an error about attempting to inherit a value from an incompatible type. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer

Re: segfault w/ localvar_inherit and associative array insert

2018-07-29 Thread Grisha Levit
Though my motivation in reporting this was to point out the segfault, I'm a bit confused by why compound assignment should be an error here. > Bash is consistent in defaulting to indexed array variables when you don't > specify -A and assign a value using the compound assignment syntax. Since loc

Re: segfault w/ localvar_inherit and associative array insert

2018-07-27 Thread Chet Ramey
On 7/26/18 3:15 PM, Grisha Levit wrote: > 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

Re: segfault w/ localvar_inherit and associative array insert

2018-07-26 Thread Grisha Levit
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) * w

Re: segfault w/ localvar_inherit and associative array insert

2018-07-26 Thread Chet Ramey
On 7/25/18 5:37 PM, Grisha Levit wrote: > shopt -s localvar_inherit > declare -A var > f() { declare var+=([0]=X); }; f This should be an error due to mismatched array types. The local variable is an indexed array; the global variable is an associative array (though it is unset). You can't inheri

segfault w/ localvar_inherit and associative array insert

2018-07-25 Thread Grisha Levit
shopt -s localvar_inherit declare -A var f() { declare var+=([0]=X); }; f Segmentation fault: 11 * thread #1, stop reason = signal SIGSTOP * frame #0: 0x000107abb72f bash`hash_search + 47 frame #1: 0x000107ac7324 bash`assoc_insert + 36 frame #2: 0x000107ac6658 bash`assign_co