逃离红宝石中的空格

时间:2018-03-21 20:45:57

标签: ruby powershell chef

当我执行以下脚本块时,出现错误:

powershell_script 'uninstall_something' do
   code 'wmic /failfast:on product where "name like 'Something Enterprise(64-bit)'" call uninstall /nointeractive'
   guard_interpreter :powershell_script
end

FATAL: SyntaxError: .\check.rb:6: syntax error, unexpected tCONSTANT, expecting keyword_end
...roduct where "name like 'Something Enterprise(64-bit)'" call un...
                                     ^
.\check.rb:6: syntax error, unexpected tSTRING_BEG, expecting keyword_end
...ike 'Something Enterprise(64-bit)'" call uninstall /nointeracti...
                                     ^

我试过逃避空间但我仍然得到错误。如果我在PowerShell中执行相同的PowerShell命令,我不会收到任何错误。 我错过了什么?

1 个答案:

答案 0 :(得分:1)

如果其他两个引号都在使用中,您可以使用%q[...]

code %q[wmic /failfast:on product where "name like 'Something Enterprise(64-bit)'" call uninstall /nointeractive]