[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: |
Fri, 21 Feb 2020 01:34:41 +0100 |
2020-02-20 21:36 GMT+01:00, Chet Ramey <chet.ramey@case.edu>:
> On 2/19/20 4:03 PM, Arfrever Frehtes Taifersar Arahesis wrote:
>> ${!variable@operator} does not work for variables without values.
>> See empty values for all occurrences of ${!var@...} below.
>>
>> ${variable@A} does not work for scalar variables without values, but
>> interestingly ${variable[@]@A} works for them.
>> See difference between ${VAR1@A} and ${VAR1[@]@A} below.
>> However neither ${variable@A} nor ${variable[@]@A} works for arrays
>> without values.
>>
>> Both ${variable@a} and ${variable[@]@a} work for scalar variables
>> without values.
>> However ${variable[@]@a} does not work for arrays without values.
>
> Same answer as previously: maybe it should display the attributes
> even thought the variable is unset.
Yes, I think that @A, [@]@A, @a and [@]@a should work for unset variables.
As mentioned previously, @a and [@]@a already works for unset scalar variables,
and @a works for unset arrays, but [@]@a does not work for unset
arrays (while it works for set arrays).
Examples for @a and [@]@a:
$ declare -lr VAR1
$ declare -lr VAR2=zzz
$ declare -alr VAR3
$ declare -alr VAR4=(zzz zzz)
$ declare -Alr VAR5
$ declare -Alr VAR6=([0]=zzz [1]=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" [1]="zzz")
declare -Arl VAR5
declare -Arl VAR6=([1]="zzz" [0]="zzz" )
$ echo "${VAR1@a}"
rl
$ echo "${VAR1[@]@a}"
rl
$ echo "${VAR2@a}"
rl
$ echo "${VAR2[@]@a}"
rl
$ echo "${VAR3@a}"
arl
$ echo "${VAR3[@]@a}"
$ echo "${VAR4@a}"
arl
$ echo "${VAR4[@]@a}"
arl arl
$ echo "${VAR5@a}"
Arl
$ echo "${VAR5[@]@a}"
$ echo "${VAR6@a}"
Arl
$ echo "${VAR6[@]@a}"
Arl Arl
$
--
Arfrever Frehtes Taifersar Arahesis
- Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a, (continued)
Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a, Chet Ramey, 2020/02/20
Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a, Chet Ramey, 2020/02/20
Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a, Chet Ramey, 2020/02/20
Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a, Chet Ramey, 2020/02/20
Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a, Chet Ramey, 2020/02/20
- Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a,
Arfrever Frehtes Taifersar Arahesis <=