2021年1月8日(金) 20:07 Oğuz <oguzismailuy...@gmail.com>:
> On Fri, Jan 8, 2021 at 2:14 PM Koichi Murase <myoga.mur...@gmail.com> wrote:
>> There is no reason to introduce a different expansion rule of
>> `((...))' from that of `$((...))'.
>
> But there already is a different expansion rule. While `((
> assoc['$key']++ ))' works, `: $(( assoc['$key']++ ))' fails with a
> bad subscript error.

Actually, that inconsistency has been fixed in Bash 5.1 to match with
the behavior of `$(( assoc['$key']++ ))', i.e., now in Bash 5.1, `((
assoc['$key']++ ))' doesn't work either.  So, `(( assoc[\$key]++ ))'
is the only working way to access the associative array in the
arithmetic command of the form `(( ... ))'.  Or, maybe you could write
`let 'assoc[$key]++'`.

--
Koichi

Reply via email to