Re: Associative array keys are not reusable in (( command
From:
Oğuz
Subject:
Re: Associative array keys are not reusable in (( command
Date:
Sun, 10 Jan 2021 21:55:26 +0200
10 Ocak 2021 Pazar tarihinde Chet Ramey <chet.ramey@case.edu> yazdı:
> So you have got (( assoc[x],b[$(uname >&2)] )), and the shell does exactly
> what you think it does with that.
>
> This is a valid arithmetic expression. The `assoc' is marked as having its
> subscript expanded once, since it has. The `b' is not, because it has not.
> So when the arithmetic evaluator gets `b[$(uname >&2)]', it expands the
> subscript.
>
> The shell could internally quote the subscript, but it doesn't do that
> right now.
If I don't know the key beforehand, like if I read it from a file or the
like, this becomes a security issue. That is my concern,
`assoc_expand_once' doesn't help in that situation.
> --
> ``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/
>
--
Oğuz