On 3/15/21 8:12 PM, Chet Ramey wrote:
I'm kicking around a change to associative array subscript expansion that
would basically force the equivalent of `assoc_expand_once' on all the
time, with additional changes to prevent unwanted double expansion in an
arithmetic expression context. The option would still exist, and still be
settable and unsettable, but have little to no effect in default mode.

For instance,

declare -A assoc
key='x],b[$(echo uname >&2)'

(( assoc[$key]++ ))
declare -p assoc

would display

declare -A assoc=(["x],b[\$(echo uname >&2)"]="1" )

This is relatively straightforward to explain to people.

It's also pretty straightforward to do for internal shell commands and
expansions: things like expression evaluation as part of word expansion,
arithmetic commands, conditional commands, and so on.

The latest push to the devel branch implements this.

It doesn't do anything with the shell builtins yet, beyond allowing
assignment to `*' and `@' associative array keys.

Chet

--
``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/

Reply via email to