summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
authorBryan McLellan <btm@loftninjas.org>2016-10-05 12:35:23 -0400
committerGitHub <noreply@github.com>2016-10-05 12:35:23 -0400
commit742ff23beb39383b0e55eb3e7fde766face6f4a5 (patch)
tree43eb6d23af5f7b0c4011385574f9f4f222336707 /lib/chef
parent1cdd613855778050dee83fbc17cced869e9a7c5c (diff)
parentaf13c7a425e990232d6ff0a1739ff81ed12b55cd (diff)
downloadchef-742ff23beb39383b0e55eb3e7fde766face6f4a5.tar.gz
Merge pull request #5381 from MsysTechnologiesllc/nim/double_quotes_parsing_error
Handling double quotes in powershell_out
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/mixin/powershell_out.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/chef/mixin/powershell_out.rb b/lib/chef/mixin/powershell_out.rb
index 74de85f86f..3e1f588319 100644
--- a/lib/chef/mixin/powershell_out.rb
+++ b/lib/chef/mixin/powershell_out.rb
@@ -34,7 +34,14 @@ class Chef
script = command_args.first
options = command_args.last.is_a?(Hash) ? command_args.last : nil
- run_command_with_os_architecture(script, options)
+ result = run_command_with_os_architecture(script, options)
+
+ if result.stderr.include? "A positional parameter cannot be found that accepts argument"
+ raise Mixlib::ShellOut::ShellCommandFailed, "Please use single escape for special characters in powershell_out. \n #{result.stderr}"
+ elsif result.stderr != ""
+ raise Mixlib::ShellOut::ShellCommandFailed, result.stderr
+ end
+ result
end
# Run a command under powershell with the same API as shell_out!
@@ -91,7 +98,8 @@ class Chef
"-InputFormat None",
]
- "powershell.exe #{flags.join(' ')} -Command \"#{script}\""
+ # without gsub user has to add double escape for double quotes in the recipe
+ "powershell.exe #{flags.join(' ')} -Command \"#{script.gsub('"', '\"')}\""
end
end
end