Skip to content

Commit

Permalink
utils: fallback to env var when detecting shell (#2147)
Browse files Browse the repository at this point in the history
Resolves: #2115
  • Loading branch information
finswimmer authored Apr 6, 2020
1 parent f76ceee commit 518b699
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion poetry/utils/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from shellingham import detect_shell

from ._compat import WINDOWS
from ._compat import Path
from .env import VirtualEnv


Expand Down Expand Up @@ -42,7 +43,17 @@ def get(cls): # type: () -> Shell
try:
name, path = detect_shell(os.getpid())
except (RuntimeError, ShellDetectionFailure):
raise RuntimeError("Unable to detect the current shell.")
shell = None

if os.name == "posix":
shell = os.environ.get("SHELL")
elif os.name == "nt":
shell = os.environ.get("COMSPEC")

if not shell:
raise RuntimeError("Unable to detect the current shell.")

name, path = Path(shell).stem, shell

cls._shell = cls(name, path)

Expand Down

0 comments on commit 518b699

Please sign in to comment.