[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [@]@A weird behaviour when IFS does not contain space
From: |
Chet Ramey |
Subject: |
Re: [@]@A weird behaviour when IFS does not contain space |
Date: |
Wed, 10 Jul 2024 09:24:03 -0400 |
User-agent: |
Mozilla Thunderbird |
On 7/4/24 2:51 AM, Emanuele Torre wrote:
Hello.
Normally, ${foo[@]@A} expands to multiple values, that are the arguments
to run a declare command that sets foo to the current value/attributes.
bash-5.2$ a=( abc xyz 123 ); declare -pa result=("${a[@]@A}")
declare -a result=([0]="declare" [1]="-a" [2]="a=([0]=\"abc\" [1]=\"xyz\"
[2]=\"123\")")
bash-5.2$ a=( abc xyz 123 ); echoargs "${a[@]@A}"
$1='declare'
$2='-a'
$3='a=([0]="abc" [1]="xyz" [2]="123")'
Today, I have noticed that if IFS is set to a value that does not
include space, [@]@A will expand to a single value
OK. Is that a problem? The man page says "when evaluated," and running the
result through `eval' -- properly quoted -- produces the expected results.
If there's an issue with making the expansion eval-safe, let's look at that.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/