fix shell for windows

This commit is contained in:
daveberrys committed 2026-07-26 18:31:36 +08:00
1 parent f7a4ae5632
commit cc1072a859
1 file changed
+17 -1
+17 -1
View File
@@ -8,6 +8,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"strings" "strings"
"runtime"
"github.com/daveberrys/guh/src/cmd" "github.com/daveberrys/guh/src/cmd"
"github.com/daveberrys/guh/src/utils" "github.com/daveberrys/guh/src/utils"
@@ -30,7 +31,22 @@ var cloneCmd = &cobra.Command{
repoName = strings.TrimSuffix(repoName, ".git") repoName = strings.TrimSuffix(repoName, ".git")
shell := os.Getenv("SHELL") shell := os.Getenv("SHELL")
if shell == "" { shell = "sh" } if shell == "" {
fmt.Println("")
if runtime.GOOS != "windows" {
fmt.Println("We couldn't find your shell! Defaulting to `sh`.")
shell = "sh"
} else {
fmt.Println("Windows being windows, it doesn't export the current shell.")
fmt.Println("Defaulting to `powershell` or `cmd`.")
for _, s := range []string{"powershell", "cmd"} {
if _, err := exec.LookPath(s); err == nil {
shell = s
break
}
}
}
}
fmt.Println("") fmt.Println("")
fmt.Printf("Spawning in a new shell: %s\n", shell) fmt.Printf("Spawning in a new shell: %s\n", shell)