There is a executbale called app, and it can take some options and command line args, -l -v, to name a few. Now I’m writing a bash script inside which app will be invoked with some options, and I did it this way,
opt_string="-l -v" # this string might change according to different conditions used in if-else
# HERE is my problem
./app ${opt_string}
Look how I invoked app, typically I just invoke it in prompt shell like this:
./app -l -v
But now in this script, would it be actually this:
./app "-l -v"
cuz ${opt_string} is a STRING quoted by "", if so I doubt whether app will run normally.
I know there might be a way around this by using eval "./app ${opt_string}", but is there any way to strip the ""?
BASH FAQ entry #50: “I’m trying to put a command in a variable, but the complex cases always fail!”