【发布时间】:2019-10-16 00:03:59
【问题描述】:
我有一个 shell 脚本,其中一部分是这样做的:
bundle exec rake parallel[${@:3}];
${@:3} 是动态的,可能类似于 -p thread11 THREAD=test_thread11,或者只是 @test.feature
rake 任务需要一个参数,但无论我尝试什么,我都无法让 shell 脚本用引号将变量括起来,而不是发送类似的东西
bundle exec rake parallel["-p thread11 THREAD=test_thread11"]
我最终发送了
bundle exec rake parallel[-p thread11 THREAD=test_thread11]
这会导致 rake 任务失败。
使用 echo 语句,我可以通过执行得到正确的输出
echo "将使用运行命令" bundle exec rake parallel["'${@:3}'"]
是否可以在将变量的值传递给任务时用引号括起来?
【问题讨论】: