From 3f01a991481dca87a09034ef8cf8ddc321d40a74 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 23 Oct 2014 09:53:14 -0700 Subject: [PATCH] provisioners/shell: rename shell_args to powershell-args --- CHANGELOG.md | 1 + plugins/provisioners/shell/config.rb | 6 +++--- plugins/provisioners/shell/provisioner.rb | 16 ++++++++-------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d46cd4a9b..bd7735db1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ BUG FIXES: - provisioners/docker: Get GPG key over SSL. [GH-4597] - provisioners/docker: Search for docker binary in multiple places. [GH-4580] - provisioners/salt: Highstate works properly with a master. [GH-4471] + - provisioners/shell: PowerShell scripts can have args. [GH-4548] - synced\_folders/nfs: Don't modify NFS exports file if no exports. [GH-4619] PLUGIN AUTHOR CHANGES: diff --git a/plugins/provisioners/shell/config.rb b/plugins/provisioners/shell/config.rb index f69f8b731..e1d046f2d 100644 --- a/plugins/provisioners/shell/config.rb +++ b/plugins/provisioners/shell/config.rb @@ -10,7 +10,7 @@ module VagrantPlugins attr_accessor :privileged attr_accessor :binary attr_accessor :keep_color - attr_accessor :shell_args + attr_accessor :powershell_args def initialize @args = UNSET_VALUE @@ -20,7 +20,7 @@ module VagrantPlugins @privileged = UNSET_VALUE @binary = UNSET_VALUE @keep_color = UNSET_VALUE - @shell_args = UNSET_VALUE + @powershell_args = UNSET_VALUE end def finalize! @@ -31,7 +31,7 @@ module VagrantPlugins @privileged = true if @privileged == UNSET_VALUE @binary = false if @binary == UNSET_VALUE @keep_color = false if @keep_color == UNSET_VALUE - @shell_args = "-ExecutionPolicy Bypass" if @shell_args == UNSET_VALUE + @powershell_args = "-ExecutionPolicy Bypass" if @powershell_args == UNSET_VALUE if @args && args_valid? @args = @args.is_a?(Array) ? @args.map { |a| a.to_s } : @args.to_s diff --git a/plugins/provisioners/shell/provisioner.rb b/plugins/provisioners/shell/provisioner.rb index 5aa19c401..3e91fd891 100644 --- a/plugins/provisioners/shell/provisioner.rb +++ b/plugins/provisioners/shell/provisioner.rb @@ -100,15 +100,15 @@ module VagrantPlugins exec_path.gsub!('/', '\\') exec_path = "c:#{exec_path}" if exec_path.start_with?("\\") - # Copy shell_args from configuration - shell_args = config.shell_args - + # Copy powershell_args from configuration + shell_args = config.powershell_args + # For PowerShell scripts bypass the execution policy unless already specified - shell_args += " -ExecutionPolicy Bypass" if config.shell_args !~ /[-\/]ExecutionPolicy/i - - # CLIXML output is kinda useless, especially on non-windows hosts - shell_args += " -OutputFormat Text" if config.shell_args !~ /[-\/]OutputFormat/i - + shell_args += " -ExecutionPolicy Bypass" if config.powershell_args !~ /[-\/]ExecutionPolicy/i + + # CLIXML output is kinda useless, especially on non-windows hosts + shell_args += " -OutputFormat Text" if config.powershell_args !~ /[-\/]OutputFormat/i + command = "#{exec_path}#{args}" command = "powershell #{shell_args.to_s} -file #{command}" if File.extname(exec_path).downcase == '.ps1'