Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Lib/test/test_venv.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,6 +772,16 @@ def test_activate_shell_script_has_no_dos_newlines(self):
error_message = f"CR LF found in line {i}"
self.assertNotEndsWith(line, b'\r\n', error_message)

@requireVenvCreate
def test_activate_fish_script_preserves_status(self):
venv_dir = pathlib.Path(self.env_dir)
rmtree(venv_dir)
script_path = venv_dir / self.bindir / 'activate.fish'
venv.create(venv_dir)
script = script_path.read_text(encoding='utf-8')
self.assertIn('return $old_status', script)
self.assertNotIn('echo "exit $old_status" | .', script)

@requireVenvCreate
def test_scm_ignore_files_git(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion Lib/venv/scripts/common/activate.fish
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
printf "%s(%s)%s " (set_color 4B8BBE) __VENV_PROMPT__ (set_color normal)

# Restore the return status of the previous command.
echo "exit $old_status" | .
return $old_status
# Output the original/"old" prompt.
_old_fish_prompt
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix ``venv``'s ``activate.fish`` prompt hook to preserve the previous command
status without sourcing ``exit`` from stdin, avoiding prompt corruption in
interactive fish sessions.
Loading