[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 00:54:35 +0100 |
Chet Ramey <chet.ramey@case.edu> 2020-02-20 21:22 UTC:
> On 2/19/20 7:46 PM, Arfrever Frehtes Taifersar Arahesis wrote:
>> But I am not interested in any ${!varname[@]}, but instead in applying
>> @operator transformations.
>
> OK, let's see how these work.
>
> Given the following
>
> VAR2=(aaa bbb)
> varname=VAR2
>
> What does
>
> echo ${!varname[@]@Q}
>
> output?
>
> You first have to expand `varname[@]' as an indirect reference. Since
> varname is a scalar variable, varname[@] expands to the same thing as
> varname, which is VAR2. Now you expand VAR2, which, since VAR2 is an
> array variable, is the same as VAR2[0]. That gives you "aaa", so the
> output is 'aaa'.
Your explanation is convincing for varname=VAR2 but now I would expect
different results for varname=VAR2[@].
Current actual results:
$ VAR2=(aaa bbb)
$ varname="VAR2[@]"
$ echo "${VAR2@Q}"
'aaa'
$ echo "${VAR2[@]@Q}"
'aaa' 'bbb'
$ echo "${!varname@Q}"
$ echo "${!varname[@]@Q}"
$
Expected results for last 2 commands:
$ echo "${!varname@Q}"
'aaa' 'bbb'
$ echo "${!varname[@]@Q}"
bash: ${VAR2[@][@]@Q}: bad substitution # This is example from
direct usage of [@][@]
$
--
Arfrever Frehtes Taifersar Arahesis
- ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a, Arfrever Frehtes Taifersar Arahesis, 2020/02/19
- Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a, Arfrever Frehtes Taifersar Arahesis, 2020/02/19
- Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a, Arfrever Frehtes Taifersar Arahesis, 2020/02/19
- Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a, Eli Schwartz, 2020/02/19
- Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a, Arfrever Frehtes Taifersar Arahesis, 2020/02/19
- Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a, Greg Wooledge, 2020/02/20
- Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a, Eli Schwartz, 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 <=
- Re: ${!variable@operator} does not work for variables without values; inconsistencies between present and absent [@] for @A and @a, Chet Ramey, 2020/02/21
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