I am using diff to format a string that includes tput color variables, and am unable to have those variables evaluated without using the "evil" eval
command.
The command that creates the string:
output1="$(diff --changed-group-format="\${RED}%=\${CLS}" <(echo -e "${nstr1}") <(echo -e "${nstr2}")|tr -d '\n')"
and outputs this:
[String n${RED}â${CLS}m${RED}è™${CLS}]
I've looked and searched other answers, but nothing is working other than:
eval echo "${output1}"
From what I have read, my 3 options are eval
(bad), indirect expansion(better), and arrays(best). Every attempt at indirection has failed. I'd love to use the array option but I am just not seeing how it would apply here. Am I missing something?
I don't think it's relevant, but the variables and the construction of strings sent to diff are in another question here.