Re: mapfile creates poorly-named array if passed nameref to array subscript

2016-06-05 Thread Chet Ramey
On 6/1/16 10:45 PM, Grisha Levit wrote: > I guess it’s even more general than just list assignments. See also below > problems with |declare|: These are all the same problem, and the same as the previous report. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ar

Re: mapfile creates poorly-named array if passed nameref to array subscript

2016-06-02 Thread Chet Ramey
On 6/1/16 6:19 PM, Grisha Levit wrote: > |$ declare -n ref=XXX[0]; mapfile ref <<< $'1\n2'; declare -p XXX[0] declare > -a XXX[0]=([0]=$'1\n' [1]=$'2\n') | > > maybe makes sense to check for legal identifier before making the array? Actually, it makes sense to check only for legal identifier inst

Re: mapfile creates poorly-named array if passed nameref to array subscript

2016-06-01 Thread Grisha Levit
I guess it’s even more general than just list assignments. See also below problems with declare: $ declare -n ref=var[123]; unset ref; declare ref=; declare -p ${!ref}declare -- var[123]="123]" $ declare -n ref=var[123]; unset ref; declare ref+=; declare -p ${!ref}declare -- var[123]="23]" $ dec

Re: mapfile creates poorly-named array if passed nameref to array subscript

2016-06-01 Thread Grisha Levit
Actually it’s a bit more general than just mapfile: $ declare -n ref=XXX[0]; declare -A ref; ref[foo]=bar $ declare -p XXX[0]declare -A XXX[0]=([foo]="bar" ) $ declare -n ref=XXX[0]; ref+=([2]=x) $ declare -p XXX[0]declare -a XXX[0]=([2]="x") $ declare -n ref=XXX[0]; read -a ref <<< "A B C" $ de

mapfile creates poorly-named array if passed nameref to array subscript

2016-06-01 Thread Grisha Levit
$ declare -n ref=XXX[0]; mapfile ref <<< $'1\n2'; declare -p XXX[0]declare -a XXX[0]=([0]=$'1\n' [1]=$'2\n') maybe makes sense to check for legal identifier before making the array? ​