bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Single quote character not handled well in associative array index


From: Wesley Hirsch
Subject: Re: Single quote character not handled well in associative array index
Date: Mon, 29 Aug 2016 23:28:47 -0400


On Mon, Aug 29, 2016 at 5:57 PM, Jarno Suni <jarno.ilari.suni@gmail.com> wrote:
declare -A a
b="80's"
((++a[$b]))
((++a["$b"]))
[[ $((++a[$b])) ]] || true
[[ $((++a["$b"])) ]] || true  # this finally works and makes the variable =1
echo ${a["$b"]}
echo ${a[$b]}

((++a[\$b]))

It's non-intuitive certainly, but let commands don't get evaluated until after the shell handles variable expansion.

Actually, that raises an interesting question about the differences between $(( and ((.  The man page says that $(( treats its contents as double quoted, however, (( is a built-in an not an expansion.  How does (( treat its contents?


)) )) )) )) ))  *grumblegrumbleunterminatedparensgrumble*

reply via email to

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