From 69b3b44505c24ea175f084bdb997f86aadaad1d3 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 13 Nov 2018 11:48:53 -0800 Subject: [PATCH] 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. --- lib/vagrant/plugin/v2/trigger.rb | 6 +++++- test/unit/vagrant/plugin/v2/trigger_test.rb | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/plugin/v2/trigger.rb b/lib/vagrant/plugin/v2/trigger.rb index d9caf21ef..055c472b0 100644 --- a/lib/vagrant/plugin/v2/trigger.rb +++ b/lib/vagrant/plugin/v2/trigger.rb @@ -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 diff --git a/test/unit/vagrant/plugin/v2/trigger_test.rb b/test/unit/vagrant/plugin/v2/trigger_test.rb index 9b88b8d41..dd4ce6b90 100644 --- a/test/unit/vagrant/plugin/v2/trigger_test.rb +++ b/test/unit/vagrant/plugin/v2/trigger_test.rb @@ -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