From 948f2ee2ada4528f8e6902c7e8f32c9c6e4722d4 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 26 Jan 2021 11:49:37 -0800 Subject: [PATCH] manage: Quote commands correctly in log_management_command. Signed-off-by: Anders Kaseorg --- manage.py | 2 +- scripts/lib/zulip_tools.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/manage.py b/manage.py index 30f8fb0e7b..c9440f8495 100755 --- a/manage.py +++ b/manage.py @@ -41,7 +41,7 @@ if __name__ == "__main__": from scripts.lib.zulip_tools import log_management_command - log_management_command(" ".join(sys.argv), settings.MANAGEMENT_LOG_PATH) + log_management_command(sys.argv, settings.MANAGEMENT_LOG_PATH) os.environ.setdefault("PYTHONSTARTUP", os.path.join(BASE_DIR, "scripts/lib/pythonrc.py")) if "--no-traceback" not in sys.argv and len(sys.argv) > 1: diff --git a/scripts/lib/zulip_tools.py b/scripts/lib/zulip_tools.py index 287160ce2d..e90a5497b1 100755 --- a/scripts/lib/zulip_tools.py +++ b/scripts/lib/zulip_tools.py @@ -203,7 +203,7 @@ def run(args: Sequence[str], **kwargs: Any) -> None: print() raise -def log_management_command(cmd: str, log_path: str) -> None: +def log_management_command(cmd: Sequence[str], log_path: str) -> None: log_dir = os.path.dirname(log_path) if not os.path.exists(log_dir): os.makedirs(log_dir) @@ -215,7 +215,7 @@ def log_management_command(cmd: str, log_path: str) -> None: logger.addHandler(file_handler) logger.setLevel(logging.INFO) - logger.info("Ran '%s'", cmd) + logger.info("Ran %s", " ".join(map(shlex.quote, cmd))) def get_environment() -> str: if os.path.exists(DEPLOYMENTS_DIR):