summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorClaire McQuin <mcquin@users.noreply.github.com>2015-10-06 14:18:19 -0700
committerClaire McQuin <mcquin@users.noreply.github.com>2015-10-06 14:18:19 -0700
commit0e0359d546ff9dd85859fad882f1cd71f745b517 (patch)
treeee1680065fcc902595671778a3a329c4fa19a3d7 /lib/chef
parenta233b5fc09d8151c429dc99c8a907ffab4664203 (diff)
parent9b57fbf80828747699695119a354f51dbb7fa4b2 (diff)
downloadchef-0e0359d546ff9dd85859fad882f1cd71f745b517.tar.gz
Merge pull request #4036 from chef/mcquin/chef-3883
Quote paths.
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/provider/powershell_script.rb19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/chef/provider/powershell_script.rb b/lib/chef/provider/powershell_script.rb
index 91ce11c337..cea9a45dad 100644
--- a/lib/chef/provider/powershell_script.rb
+++ b/lib/chef/provider/powershell_script.rb
@@ -41,10 +41,6 @@ class Chef
# Powershell.exe is always in "v1.0" folder (for backwards compatibility)
interpreter_path = Chef::Util::PathHelper.join(basepath, "WindowsPowerShell", "v1.0", interpreter)
- "\"#{interpreter_path}\" #{flags} \"#{script_file.path}\""
- end
-
- def flags
# Must use -File rather than -Command to launch the script
# file created by the base class that contains the script
# code -- otherwise, powershell.exe does not propagate the
@@ -52,8 +48,17 @@ class Chef
# end of the script, it gets changed to '1'.
#
# Nano only supports -Command
- file_or_command = Chef::Platform.windows_nano_server? ? '-Command' : '-File'
- interpreter_flags = [*default_interpreter_flags, file_or_command].join(' ')
+ cmd = "\"#{interpreter_path}\" #{flags}"
+ if Chef::Platform.windows_nano_server?
+ cmd << " -Command \". '#{script_file.path}'\""
+ else
+ cmd << " -File \"#{script_file.path}\""
+ end
+ cmd
+ end
+
+ def flags
+ interpreter_flags = [*default_interpreter_flags].join(' ')
if ! (@new_resource.flags.nil?)
interpreter_flags = [@new_resource.flags, interpreter_flags].join(' ')
@@ -91,7 +96,7 @@ EOH
# written to the file system at this point, which is required since
# the intent is to execute the code just written to it.
user_script_file.close
- validation_command = "\"#{interpreter}\" #{interpreter_arguments} -Command #{user_script_file.path}"
+ validation_command = "\"#{interpreter}\" #{interpreter_arguments} -Command \". '#{user_script_file.path}'\""
# Note that other script providers like bash allow syntax errors
# to be suppressed by setting 'returns' to a value that the