I have an external executable that I need to pass arguments to. With a bash script, I have code that determines these arguments. Some arguments may have escaped spaces. I need to then execute that string, without expanding each of the arguments.
# ... some code that determines argument string
# the following is an example of the string
ARGSTR='./executable test\ file.txt arg2=true'
exec ${ARGSTR}
I must have the $ARGSTR
be expanded so that I can pass arguments to ./executable
, but each of the arguments should not be expanded. I have tried quoting "test file.txt"
, but this still does not pass it as one argument to ./executable
.
Is there a way to do something like this?