Skip to content

Commit

Permalink
Using shlex.join() when logging a command (#490)
Browse files Browse the repository at this point in the history
* Using `shlex.join()` when logging a command

* Backport `shlex.join()`

* Fix copy-pasta
  • Loading branch information
dhermes committed Oct 2, 2021
1 parent 73d14b1 commit d95c57c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion nox/command.py
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

import os
import shlex
import sys
from typing import Any, Iterable, List, Optional, Sequence, Union

Expand Down Expand Up @@ -67,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 args)


def run(
args: Sequence[str],
*,
Expand All @@ -84,7 +90,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)

Expand Down

0 comments on commit d95c57c

Please sign in to comment.