Fixes #10393: Only use Shellwords on non-windows hosts

This commit updates how the trigger `run` inline option works by only
applying `Shellwords.split` to the inline command if it is going to be
run on non-Windows hosts. Otherwise pass the inline script directly to
be executed by Powershell.
This commit is contained in:
Brian Cain 2018-11-13 11:48:53 -08:00
parent 23b2b0b6ad
commit 69b3b44505
No known key found for this signature in database
GPG Key ID: 9FC4639B2E4510A0
2 changed files with 6 additions and 2 deletions

View File

@ -161,7 +161,11 @@ module Vagrant
# @param [Provisioners::Shell::Config] config A Shell provisioner config
def run(config, on_error, exit_codes)
if config.inline
cmd = Shellwords.split(config.inline)
if Vagrant::Util::Platform.windows?
cmd = config.inline
else
cmd = Shellwords.split(config.inline)
end
@machine.ui.detail(I18n.t("vagrant.trigger.run.inline", command: config.inline))
else

View File

@ -181,7 +181,7 @@ describe Vagrant::Plugin::V2::Trigger do
exit_codes = trigger.exit_codes
expect(Vagrant::Util::PowerShell).to receive(:execute_inline).
with("echo", "hi", options)
with("echo 'hi'", options)
subject.send(:run, shell_config, on_error, exit_codes)
end