Skip to content

Commit

Permalink
adds fallback behavior for non-ms shells
Browse files Browse the repository at this point in the history
(cherry picked from commit 770a814)
  • Loading branch information
bmarroquin authored and neersighted committed Oct 8, 2022
1 parent 59400fb commit 33e948c
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/poetry/utils/shell.py
Expand Up @@ -78,12 +78,22 @@ def activate(self, env: VirtualEnv) -> int | None:
if sys.platform == "win32":
if self._name in ("powershell", "pwsh"):
args = ["-NoExit", "-File", str(activate_path)]
else:
elif self._name == "cmd":
# /K will execute the bat file and
# keep the cmd process from terminating
args = ["/K", str(activate_path)]
completed_proc = subprocess.run([self.path, *args])
return completed_proc.returncode
else:
args = None

if args:
completed_proc = subprocess.run([self.path, *args])
return completed_proc.returncode
else:
# If no args are set, execute the shell within the venv
# This activates it, but there could be some features missing:
# deactivate command might not work
# shell prompt will not be modified.
return env.execute(self._path)

import shlex

Expand Down

0 comments on commit 33e948c

Please sign in to comment.