Skip to content

Commit

Permalink
Add strict set of allowed shells
Browse files Browse the repository at this point in the history
Updates the if else block to only allow an explicit set of shells instead of defaulting to the `activate` script.
  • Loading branch information
JoshStern authored Jul 30, 2024
1 parent 4229147 commit f5eb923
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pipenv/shells.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ def _get_activate_script(cmd, venv):
"""
# Suffix and source command for other shells.
# Support for fish shell.
if cmd.endswith("/fish"):
if cmd.endswith("/sh", "/bash", "/zsh"):
suffix = ""
command = "."
elif cmd.endswith("/fish"):
suffix = ".fish"
command = "source"
# Support for csh shell.
Expand All @@ -51,8 +54,7 @@ def _get_activate_script(cmd, venv):
suffix = ".nu"
command = "overlay use"
else:
suffix = ""
command = "."
raise ValueError(f"unknown shell {cmd}")
# Escape any special characters located within the virtualenv path to allow
# for proper activation.
venv_location = re.sub(r"([ &$()\[\]])", r"\\\1", str(venv))
Expand Down

0 comments on commit f5eb923

Please sign in to comment.