Indirect variable reference is so awkward and untransparent. You're also limited to only using strings that match proper variable syntax; only letters, digits, and the underscore are allowed, and it can't begin with a digit.
Assuming bash or another shell that supports them, an associative array would be better. Then you can use any arbitrary string:
Code:
#!/bin/bash
declare -A array
array=( [A]=1 [B]=2 [C]=3 )
for x in A B C ; do
echo "The value for entry $x is: ${array[$x]}"
done
How can I use variable variables (indirect variables, pointers, references) or associative arrays?
http://mywiki.wooledge.org/BashFAQ/006
BTW, environment variables are generally all upper-case. So while not critical, it's good practice to keep your own user variables in lower-case or mixed-case, to help differentiate them.