I have a script.
style_header[true]="background-color: rgb(230,250,230);"
style_header[false]="background-color: rgb(250,230,230);"
if COMMAND; then
    export=true
else
    export=false
fi
echo "${style_header[$export]}"
COMMAND finished ok, so export=true, but it returns style_header[false] variable "background-color: rgb(250,230,230);".
background-color: rgb(250,230,230);
I need to return this.
background-color: rgb(230,250,230);
It works with number 0 or 1 as index, but I need 'true' or 'false' variable inside.
Is possible to do that? I mean set array index as variable.

style_headeris an indexed array, so things likestyle_header[true]are processed by treating the index as an arithmetic expression. Since neithertruenorfalseis defined as a variable, they both evaluate to 0. Sostyle_header[true]andstyle_header[false]are both equivalent tostyle_header[0].