Change to /dev/tty because term.GetState fails

The file descriptor of "os.Stdin"
may cause term.GetState to be an error.
This commit is contained in:
Noboru Saito 2021-02-24 22:49:58 +09:00 committed by Garrett D'Amore
parent 14c5375ccc
commit 7694d90821
1 changed files with 6 additions and 3 deletions

View File

@ -103,11 +103,14 @@ func (t *tScreen) disengage() {
func (t *tScreen) initialize() error {
var err error
t.out = os.Stdout
t.in = os.Stdin
t.saved, err = term.GetState(int(os.Stdin.Fd()))
if err != nil {
if t.in, err = os.Open("/dev/tty"); err != nil {
return err
}
t.saved, err = term.GetState(int(t.in.Fd()))
if err == nil {
return nil
}
return nil
}