Hi,
I'd like to pass arguments with space inside to a bash script and further into an executable called inside the script. My bash script looks like:
Code:
#!/bin/bash
ARG_OPTS=""
while [[ -n "$1" ]];
        ARG_OPTS="${ARG_OPTS} $1"
        shift
done
my_executable ${ARG_OPTS}
one of the arguments to the executable is like
--options='-t 0 -v 0'
To prevent it from being splitted by the spaces when first passing to the bash script, i.e. "--options='-t", "0", "-v" and "0", I double quote it as
"--options='-t 0 -v 0'"
So '-t 0 -v 0' as a whole will be able to preserved until reaching the command invoking the executable. However '-t 0 -v 0' is not passed as a whole into the executable, but split by spaces again. This may sounds like it is the problem of calling the executable, however when directly invoking the executable from terminal
my_executable --options='-t 0 -v 0'
could be passed successfully as argument. So can
my_executable --options="-t 0 -v 0"
.

Hope that I could explain my question clearly. Shall I change the argument format or the bash script. Really appreciate your advice!