From ff77e26c5a0172062e04f5070b375e2807e0e5b0 Mon Sep 17 00:00:00 2001
From: Niklas Kappel <niklas.kappel@kit.edu>
Date: Sun, 7 May 2023 19:58:28 +0200
Subject: [PATCH] send \r to fish when using poetry shell to execute source
 command (#7884)

---
 src/poetry/utils/shell.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/poetry/utils/shell.py b/src/poetry/utils/shell.py
index d5b23288540..38457206b8b 100644
--- a/src/poetry/utils/shell.py
+++ b/src/poetry/utils/shell.py
@@ -108,9 +108,11 @@ def activate(self, env: VirtualEnv) -> int | None:
                 # Under ZSH the source command should be invoked in zsh's bash emulator
                 c.sendline(f"emulate bash -c '. {shlex.quote(str(activate_path))}'")
         else:
-            c.sendline(
-                f"{self._get_source_command()} {shlex.quote(str(activate_path))}"
-            )
+            cmd = f"{self._get_source_command()} {shlex.quote(str(activate_path))}"
+            if self._name == "fish":
+                # Under fish "\r" should be sent explicitly
+                cmd += "\r"
+            c.sendline(cmd)
 
         def resize(sig: Any, data: Any) -> None:
             terminal = shutil.get_terminal_size()