🐛 修复 Windows WebTerminal

This commit is contained in:
naiba
2021-08-19 00:04:09 +08:00
parent 2d30b2cf47
commit 7990689949
10 changed files with 26 additions and 9 deletions

View File

@@ -4,12 +4,15 @@
package pty
import (
"errors"
"os"
"os/exec"
opty "github.com/creack/pty"
)
var defaultShells = []string{"zsh", "fish", "bash", "sh"}
type Pty struct {
tty *os.File
cmd *exec.Cmd
@@ -19,9 +22,15 @@ func DownloadDependency() {
}
func Start() (*Pty, error) {
shellPath := os.Getenv("SHELL")
var shellPath string
for i := 0; i < len(defaultShells); i++ {
shellPath, _ = exec.LookPath(defaultShells[i])
if shellPath != "" {
break
}
}
if shellPath == "" {
shellPath = "sh"
return nil, errors.New("没有可用终端")
}
cmd := exec.Command(shellPath)
cmd.Env = append(os.Environ(), "TERM=xterm")