Support array values in command

Description of command in CFN User Guide:

Either an array or a string specifying the command to run. If you use
an array, you do not need to escape space characters or enclose
command parameters in quotes.

So we escape double quote first, and enclose each array value in
double quote.

Fixes bug #1211605

Change-Id: I28ecdb0d4b8a12690dddeac4e2398264c6d6f212
This commit is contained in:
JUN JIE NAN 2013-08-13 11:19:38 +08:00
parent 5b83c132a3
commit 2044ef239d
1 changed files with 5 additions and 3 deletions

View File

@ -872,9 +872,11 @@ class CommandsHandler(object):
if "command" in properties:
try:
# TODO(pfreund) aws doc : "Either an array or a string
# specifying the command to run" Need the array.
command = CommandRunner(properties["command"])
command = properties["command"]
if isinstance(command, list):
escape = lambda x: '"%s"' % x.replace('"', '\\"')
command = ' '.join(map(escape, command))
command = CommandRunner(command)
command.run('root', cwd, env)
command_status = command.status
except OSError as e: