-
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathshell_test.go
More file actions
36 lines (30 loc) · 654 Bytes
/
shell_test.go
File metadata and controls
36 lines (30 loc) · 654 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//go:build ignore
package main
import (
"fmt"
"os/exec"
"github.com/google/shlex"
)
func checkShellAvailable(command string) bool {
parts, err := shlex.Split(command)
if err != nil || len(parts) == 0 {
return false
}
_, err = exec.LookPath(parts[0])
return err == nil
}
func main() {
shells := []string{
"pwsh.exe -NoLogo",
"powershell.exe -NoLogo",
"cmd.exe",
"bash.exe",
"wsl.exe -e bash",
}
for _, shell := range shells {
available := checkShellAvailable(shell)
parts, _ := shlex.Split(shell)
path, err := exec.LookPath(parts[0])
fmt.Printf("%s: available=%v, path=%v, err=%v\n", shell, available, path, err)
}
}