I am new to bash, but this should be a very common scenario. I have the following bash “pseudoscript”
VAR1=oldValue
VAR2=var2
COMMAND="-option1 "$VAR1" -option2 "$VAR2
run $COMMAND $OTHERSTUFF
VAR1=newValue
run $COMMAND $OTHERSTUFF
#$COMMAND is stil using oldValue
Should I use eval to generate a new value for the COMMAND variable?
Use an array
If you don’t want to assign directly to the array, use functions to encapsulate the gory details:
Thought just occurred to me — this might be simpler: