I definitely got different results when I added single quotes.
Well, yes... The point I was trying to make before (and which Chet
seemed to confirm) is that the quotes break the $((..)) expression
completely, even if 'i' there is just a number, and not any fancier than
that.
And with ((..)), the command substitution runs with a slightly different
i, quotes or not and with $i or i:
$ i='a[$(date >&2)]'
$ (( a[$i]++ ))
Thu Jun 6 16:46:06 EEST 2019
bash5.0.3: a[]: bad array subscript
bash5.0.3: a[]: bad array subscript
$ (( a[i]++ ))
Thu Jun 6 16:46:12 EEST 2019
$ (( 'a[$i]++' ))
Thu Jun 6 16:46:18 EEST 2019
$ (( 'a[i]++' ))
Thu Jun 6 16:46:31 EEST 2019
So if we want "valid" values in the index to work, and invalid ones to
not do anything nasty, I can't seem to find a case where quotes would
help with that.