summaryrefslogtreecommitdiff
path: root/lib/chef/mixin/powershell_out.rb
diff options
context:
space:
mode:
authorNimishaS <nimisha.sharad@msystechnologies.com>2016-09-26 12:52:37 +0000
committerNimishaS <nimisha.sharad@msystechnologies.com>2016-09-30 12:42:03 +0000
commit31c04a1338e1c2dd0e1332a4e4af7bca4fa2f82a (patch)
treeee0f959a42df63d6f6b9ce43411f4cc0aeda7160 /lib/chef/mixin/powershell_out.rb
parent4f738f8aaf0fb6f1ee0f24a123640d5abf57a800 (diff)
downloadchef-31c04a1338e1c2dd0e1332a4e4af7bca4fa2f82a.tar.gz
Handling double quotes. Added specs
Signed-off-by: NimishaS <nimisha.sharad@msystechnologies.com>
Diffstat (limited to 'lib/chef/mixin/powershell_out.rb')
-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..67698ed5b1 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 "Please use single escape for special characters in powershell_out."
+ elsif result.stderr != ""
+ raise 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