I have a list of commands which I dynamically read in my script, each command is stored in a line. Some lines contain commands like the following
line="env_var="xxx" myexe -flag1 -flag2
I’m trying to run all lines (including these) from my script.
Then for each line I do
cmd=($line)
And then after
"${cmd[@]}"
However this fails with
env_var="xxx": command not found
I suspect the issue is that in my array declaration the part env_var="xxx"
is seen as 1 single word, and somehow I need to put syntatic equals and quotes, but I can’t seem to do it.
Any help is greatly appreciated.
Thanks!
p.s. I tried eval $line
and that works but would like to avoid that.