On 1/13/21 4:40 PM, Léa Gris wrote:
Le 13/01/2021 à 22:13, Chet Ramey écrivait :
The `-i' forces arithmetic evaluation, which makes this expand to the
equivalent of `declare -n b=1'. That's an invalid name for a nameref,
which you'd see if you used `declare -n b=1' instead. The assignment
error causes `declare' to return an non-zero status, but the error
message checks the original value, not the result of arithmetic
evaluation, and the `a[0]' is valid.
I guess I never thought people would try to use integer variables as
namerefs, since nameref values can't be digits.
Sorry Chet, this does not make sense to me. There is no error message.
OK, let's be clear that this sequence of commands from your message is what
we're talking about:
unset a b
declare -ai a=(1)
declare -in b="a[0]"
declare -p a b
I get this result:
declare -ai a=([0]="1")
x4: line 4: declare: b: not found
and I explained why there is no variable `b'.
I still wonder how when performing b+=number, the referenced value of a[0]
is multiplied by 2 and the added the number back to a[0]
That's exactly the bug I referred to yesterday that I said I would fix. The
one that's actually been around since 2012.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/