Skip to content

Commit

Permalink
Try breaking after "-" for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
abn committed Oct 1, 2020
1 parent 45cf6af commit 0069d55
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions poetry/utils/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,11 @@

WINDOWS = sys.platform == "win32"

if PY2:
import pipes

shell_quote = pipes.quote
else:
import shlex

shell_quote = shlex.quote

try:
from shlex import quote
except ImportError:
# PY2
from pipes import quote # noqa

if PY34:
from importlib.machinery import EXTENSION_SUFFIXES
Expand Down Expand Up @@ -288,4 +284,18 @@ def to_str(string):


def list_to_shell_command(cmd):
return " ".join(shell_quote(token) if " " in token else token for token in cmd)
tokens = []

idx = 0
for idx, token in enumerate(cmd):
if token == "-":
tokens.append(token)
break
tokens.append(
quote(token) if " " in token and token[0] not in {"'", '"'} else token
)

if idx < len(cmd) - 1:
tokens.extend(cmd[idx:])

return " ".join(tokens)

0 comments on commit 0069d55

Please sign in to comment.