How can I access an environment variable from another? I have the following in my shell
#!/usr/bin/env bash
set -x
export A_version=1.0.0
component=A
echo ${${component}_version}}
the bash script after the run gives me
temp.sh: line 9: ${${component}_version}}: bad substitution
eval "echo \$${component}_version"? would that work?eval "echo \\$${component}_version"works.component='(rm -rf ~)', then you're in a very bad place when you run that. Other (non-eval-based) parameter expansion syntax doesn't carry those risks. See also BashFAQ #48 re: whyevalis generally discouraged.eval. How about you post an answer here with one?_versionto the variable name before accessing it, so this should be reponed.