mirror of
https://github.com/daveberrys/guh.git
synced 2026-11-29 00:46:45 +08:00
fix shell for windows
This commit is contained in:
1 parent
f7a4ae5632
commit
cc1072a859
1 file changed
+17
-1
+17
-1
@@ -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)
|
||||||
|
|||||||
Reference in new issue
Block a user