Repository: jesseduffield/lazygit (language: go)

Issue:
Executing shell commands no longer works with `fish` as shell

**To Reproduce**

Run a custom shell command with `fish` set as shell.

https://github.com/user-attachments/assets/22182b30-7def-4f3e-9f7a-bce34c16a198

```
❯ lazygit --version
commit=, build date=, build source=homebrew, version=HEAD-13829d8, os=darwin, arch=arm64, git version=2.47.1

❯ git --version
git version 2.47.1
```


Discussion / hints:
Damn, this whole "use an interactive shell for running custom commands" feature keeps causing problems. A similar error happens with nushell.

A workaround could be to define an alias or function for lazygit that exports SHELL=/bin/bash before calling lazygit.

As for a fix, maybe we should look at the `$SHELL` variable and only do the interactive thing if it ends with either `/bash` or `/zsh` (any others that are commonly used?), and fall back to calling `bash` (without `-i`) if not.
I'll do the shell export thing for now as a workaround, thanks for the suggestion.

I also noticed an occasional command failure when doing a lazygit amend operation that seemed to be similarly shell related – I'll post if it pops up again.

These kind of issues do make me consider switching back to `zsh` 😅 

Fix patch:
diff --git a/pkg/commands/oscommands/os_default_platform.go b/pkg/commands/oscommands/os_default_platform.go
index f5ea96900f1..beb767723d6 100644
--- a/pkg/commands/oscommands/os_default_platform.go
+++ b/pkg/commands/oscommands/os_default_platform.go
@@ -6,16 +6,29 @@ package oscommands
 import (
 	"os"
 	"runtime"
+	"strings"
 )
 
 func GetPlatform() *Platform {
+	shell := getUserShell()
+
+	interactiveShell := shell
+	interactiveShellArg := "-i"
+	interactiveShellExit := "; exit $?"
+
+	if !(strings.HasSuffix(shell, "bash") || strings.HasSuffix(shell, "zsh")) {
+		interactiveShell = "bash"
+		interactiveShellArg = ""
+		interactiveShellExit = ""
+	}
+
 	return &Platform{
 		OS:                   runtime.GOOS,
 		Shell:                "bash",
-		InteractiveShell:     getUserShell(),
+		InteractiveShell:     interactiveShell,
 		ShellArg:             "-c",
-		InteractiveShellArg:  "-i",
-		InteractiveShellExit: "; exit $?",
+		InteractiveShellArg:  interactiveShellArg,
+		InteractiveShellExit: interactiveShellExit,
 		OpenCommand:          "open {{filename}}",
 		OpenLinkCommand:      "open {{link}}",
 	}


Test patch: