[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Associative array keys are not reusable in (( command
From: |
Koichi Murase |
Subject: |
Re: Associative array keys are not reusable in (( command |
Date: |
Fri, 8 Jan 2021 20:20:55 +0800 |
2021年1月8日(金) 20:07 Oğuz <oguzismailuysal@gmail.com>:
> On Fri, Jan 8, 2021 at 2:14 PM Koichi Murase <myoga.murase@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
- Associative array keys are not reusable in (( command, Oğuz, 2021/01/08
- Re: Associative array keys are not reusable in (( command, Koichi Murase, 2021/01/08
- Re: Associative array keys are not reusable in (( command, Chet Ramey, 2021/01/08
- Re: Associative array keys are not reusable in (( command, Oğuz, 2021/01/08
- Re: Associative array keys are not reusable in (( command, Chet Ramey, 2021/01/10
- Re: Associative array keys are not reusable in (( command, Oğuz, 2021/01/10
- Re: Associative array keys are not reusable in (( command, Chet Ramey, 2021/01/11
- Re: Associative array keys are not reusable in (( command, Greg Wooledge, 2021/01/11
- Re: Associative array keys are not reusable in (( command, Chet Ramey, 2021/01/11
- Re: Associative array keys are not reusable in (( command, Oğuz, 2021/01/11