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.`` diff --git a/pipenv/core.py b/pipenv/core.py index d97e89a7a3..3bc5e6afb9 100644 --- a/pipenv/core.py +++ b/pipenv/core.py @@ -2272,7 +2272,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)