I apologise for asking for asking such a trivial question which might have been answered here presumably a dozen times.
But I cannot get my head around what effect is preventing Bash from contentedly accepting this assignment.
I assume maybe some sort of non awareness of variable content in the forking parent which was assigned in the subshell child?
But my tries with process substitution via < <(command_that_parses_value_to_be_assigned) remained futile.
Here's what puzzles me.
compound=$(lvs --noheadings --units m --nosuffix -o name,size vg_oracle|cut -d. -f1|awk '{printf"[%s]=%d ",$1,$2}')
echo $compound
[lv_home_oracle]=20480 [lv_home_oracle_app]=40960 [lv_home_oracle_swdepot]=40960 [lv_opt_crs]=40960
unset oralvs; declare -A oralvs
oralvs=($compound)
-bash: oralvs: $compound: must use subscript when assigning associative array
echo ${!oralvs[*]}
wheras assigning the array's contents via copy and paste works well, so that I cannot see a syntax error in my intended statement.
oralvs=([lv_home_oracle]=20480 [lv_home_oracle_app]=40960 [lv_home_oracle_swdepot]=40960 [lv_opt_crs]=40960)
echo ${!oralvs[*]}
lv_home_oracle_app lv_opt_crs lv_home_oracle_swdepot lv_home_oracle
echo ${oralvs[*]}
40960 40960 40960 20480
Thank you for your kind attention and patience.
Was expecting that the array's compound keys-values assignment reading from variable or command substituion would work.
P.S. I think Bash: set associative array from variable answers my issue. The easiest for me to comprhende answer was the eval statement put in double quotes, which seems to work for me. e.g.
unset oralvs
echo ${!oralvs[*]}
eval "declare -A oralvs=($compound)"
echo ${!oralvs[*]}
lv_home_oracle_app lv_opt_crs lv_home_oracle_swdepot lv_home_oracle
echo ${oralvs[*]}
40960 40960 40960 20480
declare -iA "oralvs=($(lvs --noheadings --units m --nosuffix -o name,size vg_oracle |awk -F'[.[:space:]]+' '{printf "[%s]=%s ",$2,$3;}'))"declare -A "varname=($othervariable)"is a kind ofeval, you have to be confident about your input! See my answer