Skip to content

Commit 33e948c

Browse files
bmarroquinneersighted
authored andcommitted
adds fallback behavior for non-ms shells
(cherry picked from commit 770a814)
1 parent 59400fb commit 33e948c

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/poetry/utils/shell.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,22 @@ def activate(self, env: VirtualEnv) -> int | None:
7878
if sys.platform == "win32":
7979
if self._name in ("powershell", "pwsh"):
8080
args = ["-NoExit", "-File", str(activate_path)]
81-
else:
81+
elif self._name == "cmd":
8282
# /K will execute the bat file and
8383
# keep the cmd process from terminating
8484
args = ["/K", str(activate_path)]
85-
completed_proc = subprocess.run([self.path, *args])
86-
return completed_proc.returncode
85+
else:
86+
args = None
87+
88+
if args:
89+
completed_proc = subprocess.run([self.path, *args])
90+
return completed_proc.returncode
91+
else:
92+
# If no args are set, execute the shell within the venv
93+
# This activates it, but there could be some features missing:
94+
# deactivate command might not work
95+
# shell prompt will not be modified.
96+
return env.execute(self._path)
8797

8898
import shlex
8999

0 commit comments

Comments
 (0)