in older bash (or in sh
) that does not support declare -A
, following style can be used to emulate key/value
# key
env=staging
# values
image_dev=gcr.io/abc/dev
image_staging=gcr.io/abc/stage
image_production=gcr.io/abc/stable
img_var_name=image_$env
# active_image=${!var_name}
active_image=$(eval "echo \$$img_var_name")
echo $active_image