spunkyquagga
spunkyquagga

Reputation: 91

Escaping spaces in ruby

When I execute the following script block, I get an error:

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...
                                     ^

I have tried escaping the spaces but I still get the error. If I execute the same PowerShell command in PowerShell, I don't get any error. What am I missing?

Upvotes: 0

Views: 294

Answers (1)

tadman
tadman

Reputation: 211540

You can use %q[...] if both other quotes are already in use:

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

Upvotes: 1

Related Questions