If I have a script:
#!/bin/bash
for ARGUMENT in "$@"
do
echo $ARGUMENT
done
and run
./test.sh "hello there" my name is
I get expected output:
hello there
my
name
is
Yet I'm trying to pass arguments from another script, and want to run the command:
COMMAND="./test.sh \"hello there\" my name is"
echo $COMMAND I get what's expected:
./test.sh "hello there" my name is
HOWEVER running $COMMAND doesn't seem to respect the escaped quotes:
$COMMAND
gives output:
"hello
there"
my
name
is
"hello
and there"
are seen as separate args...
I am probably not escaping something correctly. I expect the first output above, but I'm getting quotes in my output rather them being evaluated as a way to group the bash arguments. What am I doing wrong?