I am trying to substitute a string variable (an array here), but I am getting an error. Could anyone suggest how to solve this?
COMP="MY"
MY_common_sections_to_fix=( \
".rodata" \
".data" \
)
echo ${${COMP}_common_sections_to_fix[@]}
ERROR:
${${COMP}_common_sections_to_fix[@]}: bad substitution
MY_common_sections_to_fixbut you are trying to accessL1CC_common_sections_to_fix, that's one level of non-surprise. However, the dynamic naming of variables is also problematic. You could create a variable holdingMY_common_sections_to_fixand work out how to exploit${!varname[@]}or thereabouts — untested, but${!var}references the variable with the name stored in$var. (Semi-tested: the results do not look promising. Assume that it won't work until further notice!)