From f8775b32e70d4fee3751bc262eab0d69fb88eb31 Mon Sep 17 00:00:00 2001 From: Tzu-ping Chung Date: Tue, 19 Jun 2018 23:09:12 +0800 Subject: [PATCH 1/2] Use shell=False when "run" if possible on Windows Do a "where" on the command; if it is found, prevent the intermediate COMSPEC and use CreateProcess directly. Only use shell=True if the command is not an executable. This prevents some unexpected behaviour caused by the intermediate shell process. --- pipenv/core.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pipenv/core.py b/pipenv/core.py index be67c8f5e0..0610e21477 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -2266,7 +2266,12 @@ def inline_activate_virtualenv(): def do_run_nt(script): import subprocess - p = subprocess.Popen(script.cmdify(), shell=True, universal_newlines=True) + command = system_which(script.command) + options = {'universal_newlines': True} + if command: # Try to use CreateProcess directly if possible. + p = subprocess.Popen([command] + script.args, **options) + else: # Command not found, maybe this is a shell built-in? + p = subprocess.Popen(script.cmdify(), shell=True, **options) p.communicate() sys.exit(p.returncode) From 1091ccb73fcf9f983a2b1aa492dd69434ad064d1 Mon Sep 17 00:00:00 2001 From: Dan Ryan Date: Fri, 22 Jun 2018 14:38:19 -0400 Subject: [PATCH 2/2] Added news item for feature Signed-off-by: Dan Ryan --- news/2385.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 news/2385.feature diff --git a/news/2385.feature b/news/2385.feature new file mode 100644 index 0000000000..17b3569cbb --- /dev/null +++ b/news/2385.feature @@ -0,0 +1 @@ +``pipenv run`` will now avoid spawning additional ``COMSPEC`` instances to run commands in when possible.``