In my-script, "$1" is a string of tokens, separated by whitespace.
how can I "spread" this single argument into multiple arguments to pass to another program for example
./my-script2 ...$1 # spread the string into multiple arguments, delineating by whitepace
Hopefully you understand the question, had trouble searching for answer to this.
I tried this:
./my-script2 <<< "$1"
and this:
./my-script2 "" <<< $1
and other combinations, but that didn't seem to work. I need to support Bash v3 and above.
Best Answer
Unquoted parameters are subject to word splitting when expanded:
This is the specified POSIX behaviour, though some shells (notably zsh) disable it by default. If you've changed the value of
IFS
from the default, that's on you.