【发布时间】:2014-04-26 10:40:41
【问题描述】:
我正在使用 ruby 执行系统命令。代码是这样的
commandtoexecute=“pararellrspec --type rspec -n 1 --test-options '--test "cases's owner"' testing/multi/getcreate.rb “
system(commandtoexecute)
在执行上述行时,它给出了错误
sh: -c: line 0: unexpected EOF while looking for matching `"'
sh: -c: line 1: syntax error: unexpected end of file
但是当我通过用上面的案例替换案例来执行时,它可以工作。有没有人知道如何在不将“cases”替换为“cases”的情况下防止上述错误
【问题讨论】:
-
你试过转义它`'..."cases\'s owner"...'吗?
-
不能那样做。字符串 "--test "cases's owner"" 存储在一个变量中,该变量在发出命令时被替换。所以没有办法尝试案例的