WHen I write a bash program I typically construct calls like follows:
declare -a mycmd=( command.ext \"arg1 with space\" arg2 thing etc )
\"${mycmd[@]}\" || ech
I like to put the code in a function so it is easier to reuse and document:
function myjoin
{
local list=("${@}")
echo $(printf "'%s', " "${list[@]}")
}
declare -a colorlist=()
colorlist+=('blue')
colorlist+=('red')
colorlist+=('orange')
echo "[$(myjoin ${colorlist[@]})]"
Note how I added the comma in the solution because I am generating code with a bash script.
[EDIT: fix problem that EM0 pointed out that it is returning ['blue',]]