Skip to content

Commit

Permalink
Change to /dev/tty because term.GetState fails
Browse files Browse the repository at this point in the history
The file descriptor of "os.Stdin"
may cause term.GetState to be an error.
  • Loading branch information
noborus authored and gdamore committed Apr 18, 2021
1 parent 14c5375 commit 7694d90
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tscreen_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 7694d90

Please sign in to comment.