change liner source so that we can have good tty config

This commit is contained in:
Aidan 2020-07-22 23:00:25 -07:00
parent f69532d54c
commit 91498926d5
No known key found for this signature in database
GPG key ID: 327711E983899316
4 changed files with 14 additions and 3 deletions

View file

@ -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)

1
go.mod
View file

@ -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

2
go.sum
View file

@ -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=

View file

@ -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