From bbca211225bd81d23dda1f7f8dde0b4e2cef6105 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Thu, 11 Apr 2019 23:41:53 +0530 Subject: [PATCH] qa: looks for quotes in Python shell and get rid of them Since quotes are not a token for Python's shell simulation (unlike Bash), raise a RuntimeError for them and add an exception for Python command since it quotes to define a program on commandline. Signed-off-by: Rishabh Dave --- qa/tasks/vstart_runner.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/qa/tasks/vstart_runner.py b/qa/tasks/vstart_runner.py index 5555eae9c52..4991ef24729 100644 --- a/qa/tasks/vstart_runner.py +++ b/qa/tasks/vstart_runner.py @@ -248,6 +248,21 @@ class LocalRemote(object): except ValueError: pass + # Quotes don't work in Python's shell simulation as a bash user would + # expect. However, it works fine it has special meaning for the given + # command (writing a small python program on the command line). + if 'sudo' in args and 'python' not in args and \ + 'python2' not in args and 'python3' not in args: + if '-c' in args: + args_to_check = args[args.index('-c') + 1 : ] + else: + args_to_check = args + + for arg in args_to_check: + if arg.find("'") != -1 or arg.find('"') != -1: + raise RuntimeError("Don't surround commands by " + "single/double quotes") + if omit_sudo: args = [a for a in args if a != "sudo"] -- 2.39.5