[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Behaviour of test -v with assoc array and quote character in key
From: |
Greg Wooledge |
Subject: |
Re: Behaviour of test -v with assoc array and quote character in key |
Date: |
Tue, 23 Feb 2021 10:55:06 -0500 |
Oğuz (oguzismailuysal@gmail.com) wrote:
> `(( assoc[\$var]++ ))' works fine as usual.
unicorn:~$ bash-5.1
unicorn:~$ declare -A hash
unicorn:~$ key=\'\]
unicorn:~$ hash[$key]=17
unicorn:~$ (( hash[\$key]++ ))
unicorn:~$ declare -p hash
declare -A hash=(["']"]="18" )
unicorn:~$ (( 'hash[$key]'++ ))
bash-5.1: ((: 'hash[']]'++ : syntax error: operand expected (error token is
"'hash[']]'++ ")
unicorn:~$ (( hash['$key']++ ))
bash-5.1: ((: hash['']']++ : syntax error: invalid arithmetic operator (error
token is "']++ ")
unicorn:~$ (( hash['$'key]++ ))
unicorn:~$ declare -p hash
declare -A hash=(["\$key"]="1" ["']"]="18" )
I understand absolutely none of this. Quoting the $ works, but only
if you quote it with a backslash, not with single quotes? And quoting
any other characters besides the $ fails?
Sorry, I'm still going with "this stuff's broken -- don't use it".
- Re: Behaviour of test -v with assoc array and quote character in key, (continued)
- Re: Behaviour of test -v with assoc array and quote character in key, Greg Wooledge, 2021/02/23
- Re: Behaviour of test -v with assoc array and quote character in key, Léa Gris, 2021/02/23
- Re: Behaviour of test -v with assoc array and quote character in key, Greg Wooledge, 2021/02/23
- Re: Behaviour of test -v with assoc array and quote character in key, Andreas Schwab, 2021/02/23
- Re: Behaviour of test -v with assoc array and quote character in key, Greg Wooledge, 2021/02/23
- Re: Behaviour of test -v with assoc array and quote character in key, Oğuz, 2021/02/23
- Re: Behaviour of test -v with assoc array and quote character in key,
Greg Wooledge <=
- Re: Behaviour of test -v with assoc array and quote character in key, Oğuz, 2021/02/23
- Re: Behaviour of test -v with assoc array and quote character in key, Chet Ramey, 2021/02/23