bug-bash
[Top][All Lists]
Advanced

[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: Oğuz
Subject: Re: Behaviour of test -v with assoc array and quote character in key
Date: Tue, 23 Feb 2021 18:05:51 +0200

23 Şubat 2021 Salı tarihinde Greg Wooledge <greg@wooledge.org> yazdı:

> 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?


Neither do I :D I was told in this list that quote removal rules for `((
... ))' were changed recently, but I have yet to understand why and how.


>
> Sorry, I'm still going with "this stuff's broken -- don't use it".
>

I agree with this.


-- 
Oğuz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]