cloudmonkey: Fix cloudmonkey command line arg cleaning Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
diff --git a/cloudmonkey/cloudmonkey.py b/cloudmonkey/cloudmonkey.py index 32f0d79..e3790d3 100644 --- a/cloudmonkey/cloudmonkey.py +++ b/cloudmonkey/cloudmonkey.py
@@ -759,9 +759,21 @@ if len(args.commands) > 0: shell.set_attr("color", "false") - shell.onecmd(" ".join(map(lambda x: x.replace("\\ ", " ") - .replace(" ", "\\ "), - args.commands))) + commands = [] + for command in args.commands: + split_command = command.split("=") + if len(split_command) > 1: + key = split_command[0] + value = split_command[1] + if " " not in value or \ + (value.startswith("\"") and value.endswith("\"")) or \ + (value.startswith("\'") and value.endswith("\'")): + commands.append(command) + else: + commands.append("%s=\"%s\"" % (key, value)) + else: + commands.append(command) + shell.onecmd(" ".join(commands)) if shell.error_on_last_command: sys.exit(1) else: