Please reopen. This is not a duplicate, because here I am asking why it doesn't work, not just for workaround.
Bash manual says that
tilde expansion, parameter and variable expansion, arithmetic expansion, and command substitution (done in a left-to-right fashion)
If I understand http://unix.stackexchange.com/a/270324/674 correctly, "left-to-right" means that "brace expansion; tilde expansion, parameter and variable expansion, arithmetic expansion, and command substitution" have the same priority.
So is it possible to use arithmetic expansion inside parameter expansion? (i.e. one level recursion)
If no, why can't arithmetic expansion work inside parameter expansion, given that "tilde expansion, parameter and variable expansion, arithmetic expansion, and command substitution (done in a left-to-right fashion)"?
If yes, how?
For example,
$ set hello world
$ echo $2
world
$ echo ${$((1+1))}
bash: ${$((1+1))}: bad substitution
I hope to
- first expand
$((1+1))in${$((1+1))}to2. and - then
${2}toworld.
Thanks.