How can I pass an array where some values have spaces. I mean:
script.sh
#/bin/bash
echo $1, $#
I can run this little script
$ ./script.sh a --> a, 1
$ ./script.sh "a b" --> a b, 1
$ v=("a b" c)
$ ./script.sh ${v[@]} --> a, 3
$ ./script.sh ${v[@]@Q} --> 'a, 3
I would like to print "a b, 2" without changing the script Is it possible?
The only way I have found to achive it is:
eval "./script.sh ${v[@]@Q}" --> a b, 2
Is there a smarter way?