bug-bash
[Top][All Lists]
Advanced

[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: Thu, 26 Jul 2018 15:15:31 -0400

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=()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]