Skip to content

Commit

Permalink
Merge pull request #374 from smoynes/raw-mode-warning
Browse files Browse the repository at this point in the history
Improve warning message when stdin is not a terminal
  • Loading branch information
dnephin committed Oct 12, 2023
2 parents 44e8c11 + f715105 commit 4c5af78
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/filewatcher/term_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,16 @@ func newTerminal() *terminal {
}

// Start the terminal is non-blocking read mode. The terminal can be reset to
// normal mode by calling Reset.
// normal mode by calling Reset. If os.Stdin is not a terminal or cannot use
// non-blocking reads then a warning is logged and the terminal is not reset.
func (r *terminal) Start() {
if r == nil {
return
}
fd := int(os.Stdin.Fd())
reset, err := enableNonBlockingRead(fd)
if err != nil {
log.Warnf("failed to put terminal (fd %d) into raw mode: %v", fd, err)
log.Warnf("no terminal input -- keyboard shortcuts disabled: %v", err)
return
}
r.reset = reset
Expand Down

0 comments on commit 4c5af78

Please sign in to comment.