|
| From: | Chet Ramey |
| Subject: | Re: declare does not always set variable flags prior to assignment |
| Date: | Fri, 8 Oct 2021 13:43:06 -0400 |
| User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.1.2 |
On 10/4/21 10:17 AM, Léa Gris wrote:
Found out that the declare statement does not properly set all variable flags before assign values:unset arr declare -i -a arr=(1 2 3) declare -p arrdeclare -ai arr=([0]="1" [1]="2" [2]="3")this is ok declare +i -a arr=(hello world) declare -p arrdeclare -a arr=([0]="0" [1]="0")this is not ok as arr assignment was handled as integers
It's an interesting order-of-operations question. You can make a case that
the shell should unset the attributes before expanding the words in the
compound assignment statement, since we special-case setting the attributes
for declaration commands. Let me look at that.
Chet
--
``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/
| [Prev in Thread] | Current Thread | [Next in Thread] |