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


Groups > gnu.bash.bug > #14412

Re: segfault w/ localvar_inherit and associative array insert

From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: segfault w/ localvar_inherit and associative array insert
Date 2018-07-27 11:38 -0400
Message-ID <mailman.4337.1532705898.1292.bug-bash@gnu.org> (permalink)
References <CAMu=BroMwXaqDTT3qusycRGRdXevmxiwC0RpR8+wGooo83pWgg@mail.gmail.com> <2e51ae31-5fb0-633b-6d7b-faab8df39585@case.edu> <CAMu=Brpvrg2GHwy8zs5hiWN_cReUupa=014JmfCNKMxaJws2Bw@mail.gmail.com>

Show all headers | View raw


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 is not already an existing local variable)
>    * we are performing a compound assignment/append operation in the
>      same declare command

Exactly. Look at the third point. A statement like `declare x+=( [0]=foo)'
means to create a local array variable, since the -A option is not
supplied. Bash is consistent in defaulting to indexed array variables when
you don't specify -A and assign a value using the compound assignment
syntax. So you create a local indexed array variable, and when you attempt
to inherit the value from a global associative array before performing any
specified assignment, you should either ignore the inherited value or throw
an error.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
		 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    chet@case.edu    http://tiswww.cwru.edu/~chet/

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: segfault w/ localvar_inherit and associative array insert Chet Ramey <chet.ramey@case.edu> - 2018-07-27 11:38 -0400

csiph-web