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: Fri, 21 Feb 2020 00:23:24 +0100

Chet Ramey <chet.ramey@case.edu> 2020-02-20 20:41 UTC:
> On 2/19/20 5:22 PM, Arfrever Frehtes Taifersar Arahesis wrote:
>>> ${variable@A} does not work for scalar variables without values, but
>>> interestingly ${variable[@]@A} works for them.
>>
>> More precisely, ${variable[@]@A} is non-empty, but not exactly correct.
>>
>>> See difference between ${VAR1@A} and ${VAR1[@]@A} below.
>>
>> ${VAR1[@]@A} is:
>> declare -rl VAR1=''"
>> But should be:
>> declare -rl VAR1
>> As in output of 'declare -p VAR1'.
>
> The output is two blank lines:
>
> $ cat x6b
> declare -lr VAR1
>
> echo ${VAR1@A}
> echo ${VAR1[@]@A}
> $ ../bash-5.0-patched/bash ./x6b
>
>

Even more strangely, quoting apparently matters...

$ declare -lr VAR1
$ echo ${VAR1@A}

$ echo ${VAR1[@]@A}

$ echo "${VAR1@A}"

$ echo "${VAR1[@]@A}"
declare -rl VAR1=''
$ declare -p VAR1
declare -rl VAR1
$

> The question is whether the unset variables should display commands to
> set the attributes (@A) or display any attributes (@a).

I think that it would be expected that @A prints the same as 'declare
-p' for given variable.

--
Arfrever Frehtes Taifersar Arahesis



reply via email to

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