diff --git a/cmd/shs.go b/cmd/shs.go index 739b917..6ac73dd 100644 --- a/cmd/shs.go +++ b/cmd/shs.go @@ -21,7 +21,7 @@ import ( "os" "fmt" "strconv" - "github.com/peterh/liner" + "github.com/candid82/liner" "gitlab.com/whom/shs/ast" "gitlab.com/whom/shs/log" "gitlab.com/whom/shs/util" @@ -109,6 +109,12 @@ func main() { line := liner.NewLiner() defer line.Close() + if !liner.TerminalSupported() { + log.Log(log.ERR, + "Terminal unsupported, continuing in dummy mode!", + "init") + } + line.SetCtrlCAborts(true) line.SetCompleter(func(line string) (c []string) { return util.ShellCompleter(line, vars, funcs) diff --git a/go.mod b/go.mod index 63a9008..7b6cc51 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module gitlab.com/whom/shs go 1.14 require ( + github.com/candid82/liner v1.4.0 // indirect github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e // indirect github.com/peterh/liner v1.2.0 // indirect golang.org/x/sys v0.0.0-20200720211630-cb9d2d5c5666 diff --git a/go.sum b/go.sum index ee825b8..dbd0289 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/candid82/liner v1.4.0 h1:nUhs4pv/cnpnBERwJHmqmgargZTWnPbDJ67HtQcfSTo= +github.com/candid82/liner v1.4.0/go.mod h1:shD5EWTOYasmaGjMfuaB82N9YxGMIAEoXjQEH6RoGvo= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/mattn/go-runewidth v0.0.3 h1:a+kO+98RDGEfo6asOGMmpodZq4FNtnGP54yps8BzLR4= diff --git a/stdlib/shell.go b/stdlib/shell.go index ba12cf5..68afea0 100644 --- a/stdlib/shell.go +++ b/stdlib/shell.go @@ -91,7 +91,7 @@ func waitHandler() { exit = -1024 var e *exec.ExitError if errors.As(w, &e) { - exit = e.Pid() + exit = e.ExitCode() } LastExitCode = exit @@ -156,7 +156,9 @@ func InitShellFeatures() bool { func TeardownShell() { close(sigChan) close(waitChan) - // TODO: Exit all processes in the JobMap + for k := range JobMap { + JobMap[k].Cancel() + } } /* Makes and stores a new process in the job control