I have a shell script where part of it does this:
bundle exec rake parallel[${@:3}];
${@:3} is dynamic and could be something like -p thread11 THREAD=test_thread11, or just @test.feature
The rake task is expecting one argument but no matter what I try I can't get the shell script to surround the variable with quotes so instead of sending something like
bundle exec rake parallel["-p thread11 THREAD=test_thread11"]
I end up sending
bundle exec rake parallel[-p thread11 THREAD=test_thread11]
Which causes the rake task to fail.
With an echo statement I can get the correct output by doing
echo "Will use run command" bundle exec rake parallel["'${@:3}'"]
Is it possible to surround the value of the variable with quotes when passing it to the task?
It appears you want to use "${*:3}"
instead, which will produces a single space-delimited word from the 3 arguments rather than a series of individuals words, one per argument.