Commit 518b6993 by finswimmer Committed by GitHub

utils: fallback to env var when detecting shell (#2147)

Resolves: #2115
parent f76ceee0
...@@ -9,6 +9,7 @@ from shellingham import ShellDetectionFailure ...@@ -9,6 +9,7 @@ from shellingham import ShellDetectionFailure
from shellingham import detect_shell from shellingham import detect_shell
from ._compat import WINDOWS from ._compat import WINDOWS
from ._compat import Path
from .env import VirtualEnv from .env import VirtualEnv
...@@ -42,8 +43,18 @@ class Shell: ...@@ -42,8 +43,18 @@ class Shell:
try: try:
name, path = detect_shell(os.getpid()) name, path = detect_shell(os.getpid())
except (RuntimeError, ShellDetectionFailure): except (RuntimeError, ShellDetectionFailure):
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.") raise RuntimeError("Unable to detect the current shell.")
name, path = Path(shell).stem, shell
cls._shell = cls(name, path) cls._shell = cls(name, path)
return cls._shell return cls._shell
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment