Skip to content

Commit

Permalink
Merge pull request #2385 from pypa/avoid-shell-in-run-if-possible
Browse files Browse the repository at this point in the history
Use shell=False when "run" if possible on Windows
  • Loading branch information
techalchemy authored Jun 22, 2018
2 parents 82bf57a + 1091ccb commit fde4a89
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/2385.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
``pipenv run`` will now avoid spawning additional ``COMSPEC`` instances to run commands in when possible.``
7 changes: 6 additions & 1 deletion pipenv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit fde4a89

Please sign in to comment.