Re: Single quote character not handled well in associative array index
On 8/29/16 5:57 PM, Jarno Suni wrote: > Bash Version: 4.3 > Patch Level: 46 > Release Status: release > > Description: > Using associative array variable that has a single quote in index does > not work withing (( )) without a trick. I'm working on a shell option that will make this work closer to how you'd like. Backwards compatibility means it won't be on by default. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
Re: Single quote character not handled well in associative array index
On 8/29/16 11:28 PM, Wesley Hirsch wrote: > 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? The `((' command is intended to be equivalent to `let'. That is, (( ... )) is equivalent to let "...". The man page and info document say exactly that. -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
Re: Single quote character not handled well in associative array index
On 8/29/16 5:57 PM, Jarno Suni wrote: > Bash Version: 4.3 > Patch Level: 46 > Release Status: release > > Description: > Using associative array variable that has a single quote in index does > not work withing (( )) without a trick. Yes, this is a problem resulting from the subscript being scanned twice (once to perform variable expansion before the expression evaluator is called, and once during the expression evaluation to find the end of the subscript). I'll look at it after bash-4.4 is released. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/
Re: Single quote character not handled well in associative array index
On Mon, Aug 29, 2016 at 11:28:47PM -0400, Wesley Hirsch wrote: > ((++a[\$b])) These three also work: (('++a[$b]')) (('++a["$b"]')) : $((++a["$b"])) But yes, this does seem like a bug.
Re: Single quote character not handled well in associative array index
On Mon, Aug 29, 2016 at 5:57 PM, Jarno Suni 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*