How can I setup ecma formatting in Bash?


function changeGrubThemeFolder {
#clear
option1="$HOME/Dropbox/My_Documents/Backup/Linux/themes                ${green}If connected to Dropbox${clear}"
option2=$'"/etc/grub.d/themes                                          ${green}If not connected to Dropbox${clear}"'
option3=$'"custon entry                                                ${green}Location of your choosing${clear}"'

echo; echo "Select desired theme directory"; echo

select rb in "$option1" "$option2" "$option3" "Exit"; do
  case $rb in
    "$option1")
      GRUB_THEME_FOLDER="$HOME/Dropbox/My_Documents/Backup/Linux/themes";writeChangeGrub; break;;
    "$option2")
      GRUB_THEME_FOLDER="/etc/grub.d/themes";writeChangeGrub; break;;
    "$option3")
      echo
      customChangeGrubThemeFolder;writeChangeGrub; break;;
    "Exit")
      echo
      echo "Exiting the script without a selection, no changes were made"; break;;
    *)
      echo "Invalid selection.";;
  esac
done
               
}

In the code example, I set a variable named option 1, it contains two variables. One for the $HOME directory which expands and works, the other is for the ecma formatting code which doesn’t work as a variable.

The ecma code works IF I change the variable declaration to be within single quotes after a $:

option1=$'"$HOME/Dropbox/My_Documents/Backup/Linux/themes                33[99;92mIf connected to Dropbox33[1;0m"'

Changing the option1 variable in this way will get the ecma formatting code to work, but only as a code, not a variable i.e. ${blue} will not work but will expand as text.