bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ${!variable@operator} does not work for variables without values; i


From: Arfrever Frehtes Taifersar Arahesis
Subject: Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a
Date: Thu, 20 Feb 2020 00:18:45 +0100

While described problems exist, there were typos in original reproduction steps.

Corrected output also reveals another bug:
${!variable[@]@A} for (indexed or associative) arrays does not include indexes.
Example part of output:
var=VAR4
${!var@A}:    'declare -arl VAR4='zzz''
${!var[@]@A}: 'declare -arl VAR4='zzz''
${VAR4@A}:    'declare -arl VAR4='zzz''
${VAR4[@]@A}: 'declare -arl VAR4=([0]="zzz")'

${!var[@]@A} would be expected to be the same as ${VAR4[@]@A}.


Corrected full reproduction steps with better formatting of 'for' loops:

$ declare -lr VAR1
$ declare -lr VAR2=zzz
$ declare -alr VAR3
$ declare -alr VAR4=(zzz)
$ declare -Alr VAR5
$ declare -Alr VAR6=([0]=zzz)
$ declare -p VAR{1,2,3,4,5,6}
declare -rl VAR1
declare -rl VAR2="zzz"
declare -arl VAR3
declare -arl VAR4=([0]="zzz")
declare -Arl VAR5
declare -Arl VAR6=([0]="zzz" )
$ for operator in Q E P A a ; do
>   for var in VAR{1,2,3,4,5,6} ; do
>     echo "var=${var}"
>     eval "echo \"\\\${!var@${operator}}:    '\${!var@${operator}}'\""
>     eval "echo \"\\\${!var[@]@${operator}}: '\${!var[@]@${operator}}'\""
>     eval "echo \"\\\${${var}@${operator}}:    '\${${var}@${operator}}'\""
>     eval "echo \"\\\${${var}[@]@${operator}}: '\${${var}[@]@${operator}}'\""
>     echo
>   done
> done
var=VAR1
${!var@Q}:    ''
${!var[@]@Q}: ''
${VAR1@Q}:    ''
${VAR1[@]@Q}: ''

var=VAR2
${!var@Q}:    ''zzz''
${!var[@]@Q}: ''zzz''
${VAR2@Q}:    ''zzz''
${VAR2[@]@Q}: ''zzz''

var=VAR3
${!var@Q}:    ''
${!var[@]@Q}: ''
${VAR3@Q}:    ''
${VAR3[@]@Q}: ''

var=VAR4
${!var@Q}:    ''zzz''
${!var[@]@Q}: ''zzz''
${VAR4@Q}:    ''zzz''
${VAR4[@]@Q}: ''zzz''

var=VAR5
${!var@Q}:    ''
${!var[@]@Q}: ''
${VAR5@Q}:    ''
${VAR5[@]@Q}: ''

var=VAR6
${!var@Q}:    ''zzz''
${!var[@]@Q}: ''zzz''
${VAR6@Q}:    ''zzz''
${VAR6[@]@Q}: ''zzz''

var=VAR1
${!var@E}:    ''
${!var[@]@E}: ''
${VAR1@E}:    ''
${VAR1[@]@E}: ''

var=VAR2
${!var@E}:    'zzz'
${!var[@]@E}: 'zzz'
${VAR2@E}:    'zzz'
${VAR2[@]@E}: 'zzz'

var=VAR3
${!var@E}:    ''
${!var[@]@E}: ''
${VAR3@E}:    ''
${VAR3[@]@E}: ''

var=VAR4
${!var@E}:    'zzz'
${!var[@]@E}: 'zzz'
${VAR4@E}:    'zzz'
${VAR4[@]@E}: 'zzz'

var=VAR5
${!var@E}:    ''
${!var[@]@E}: ''
${VAR5@E}:    ''
${VAR5[@]@E}: ''

var=VAR6
${!var@E}:    'zzz'
${!var[@]@E}: 'zzz'
${VAR6@E}:    'zzz'
${VAR6[@]@E}: 'zzz'

var=VAR1
${!var@P}:    ''
${!var[@]@P}: ''
${VAR1@P}:    ''
${VAR1[@]@P}: ''

var=VAR2
${!var@P}:    'zzz'
${!var[@]@P}: 'zzz'
${VAR2@P}:    'zzz'
${VAR2[@]@P}: 'zzz'

var=VAR3
${!var@P}:    ''
${!var[@]@P}: ''
${VAR3@P}:    ''
${VAR3[@]@P}: ''

var=VAR4
${!var@P}:    'zzz'
${!var[@]@P}: 'zzz'
${VAR4@P}:    'zzz'
${VAR4[@]@P}: 'zzz'

var=VAR5
${!var@P}:    ''
${!var[@]@P}: ''
${VAR5@P}:    ''
${VAR5[@]@P}: ''

var=VAR6
${!var@P}:    'zzz'
${!var[@]@P}: 'zzz'
${VAR6@P}:    'zzz'
${VAR6[@]@P}: 'zzz'

var=VAR1
${!var@A}:    ''
${!var[@]@A}: ''
${VAR1@A}:    ''
${VAR1[@]@A}: 'declare -rl VAR1='''

var=VAR2
${!var@A}:    'declare -rl VAR2='zzz''
${!var[@]@A}: 'declare -rl VAR2='zzz''
${VAR2@A}:    'declare -rl VAR2='zzz''
${VAR2[@]@A}: 'declare -rl VAR2='zzz''

var=VAR3
${!var@A}:    ''
${!var[@]@A}: ''
${VAR3@A}:    ''
${VAR3[@]@A}: ''

var=VAR4
${!var@A}:    'declare -arl VAR4='zzz''
${!var[@]@A}: 'declare -arl VAR4='zzz''
${VAR4@A}:    'declare -arl VAR4='zzz''
${VAR4[@]@A}: 'declare -arl VAR4=([0]="zzz")'

var=VAR5
${!var@A}:    ''
${!var[@]@A}: ''
${VAR5@A}:    ''
${VAR5[@]@A}: ''

var=VAR6
${!var@A}:    'declare -Arl VAR6='zzz''
${!var[@]@A}: 'declare -Arl VAR6='zzz''
${VAR6@A}:    'declare -Arl VAR6='zzz''
${VAR6[@]@A}: 'declare -Arl VAR6=([0]="zzz" )'

var=VAR1
${!var@a}:    ''
${!var[@]@a}: ''
${VAR1@a}:    'rl'
${VAR1[@]@a}: 'rl'

var=VAR2
${!var@a}:    'rl'
${!var[@]@a}: 'rl'
${VAR2@a}:    'rl'
${VAR2[@]@a}: 'rl'

var=VAR3
${!var@a}:    ''
${!var[@]@a}: ''
${VAR3@a}:    'arl'
${VAR3[@]@a}: ''

var=VAR4
${!var@a}:    'arl'
${!var[@]@a}: 'arl'
${VAR4@a}:    'arl'
${VAR4[@]@a}: 'arl'

var=VAR5
${!var@a}:    ''
${!var[@]@a}: ''
${VAR5@a}:    'Arl'
${VAR5[@]@a}: ''

var=VAR6
${!var@a}:    'Arl'
${!var[@]@a}: 'Arl'
${VAR6@a}:    'Arl'
${VAR6[@]@a}: 'Arl'

$

--
Arfrever Frehtes Taifersar Arahesis



reply via email to

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