From 513af9e8ef062b153eacbe59f40afd6b5dde4299 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Fri, 1 Oct 2021 21:23:17 -0500 Subject: [PATCH 1/3] Using `shlex.join()` when logging a command --- nox/command.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nox/command.py b/nox/command.py index 5f215096..809c3c07 100644 --- a/nox/command.py +++ b/nox/command.py @@ -13,6 +13,7 @@ # limitations under the License. import os +import shlex import sys from typing import Any, Iterable, List, Optional, Sequence, Union @@ -84,7 +85,7 @@ def run( success_codes = [0] cmd, args = args[0], args[1:] - full_cmd = f"{cmd} {' '.join(args)}" + full_cmd = f"{cmd} {shlex.join(args)}" cmd_path = which(cmd, paths) From 0fc17cfbc142f92cc6fb706d6320269fabc6e70a Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Fri, 1 Oct 2021 21:32:40 -0500 Subject: [PATCH 2/3] Backport `shlex.join()` --- nox/command.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nox/command.py b/nox/command.py index 809c3c07..2c2417d1 100644 --- a/nox/command.py +++ b/nox/command.py @@ -68,6 +68,11 @@ def _clean_env(env: Optional[dict]) -> Optional[dict]: return clean_env +def _shlex_join(args: Sequence[str]) -> str: + # shlex.join() was added in Python 3.8 + return " ".join(shlex.quote(arg) for arg in split_command) + + def run( args: Sequence[str], *, @@ -85,7 +90,7 @@ def run( success_codes = [0] cmd, args = args[0], args[1:] - full_cmd = f"{cmd} {shlex.join(args)}" + full_cmd = f"{cmd} {_shlex_join(args)}" cmd_path = which(cmd, paths) From 32317a68ea31eadd40f76543bf3cf3632b0947a4 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Fri, 1 Oct 2021 21:37:17 -0500 Subject: [PATCH 3/3] Fix copy-pasta --- nox/command.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nox/command.py b/nox/command.py index 2c2417d1..b26f58df 100644 --- a/nox/command.py +++ b/nox/command.py @@ -70,7 +70,7 @@ def _clean_env(env: Optional[dict]) -> Optional[dict]: def _shlex_join(args: Sequence[str]) -> str: # shlex.join() was added in Python 3.8 - return " ".join(shlex.quote(arg) for arg in split_command) + return " ".join(shlex.quote(arg) for arg in args) def run(