mirror of
https://github.com/restic/restic.git
synced 2024-12-23 00:07:25 +00:00
termstatus: detect and respect dumb terminals on Unix
Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
This commit is contained in:
parent
6bc99ce451
commit
541d232f1c
1 changed files with 10 additions and 1 deletions
|
@ -4,6 +4,7 @@ package termstatus
|
|||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"golang.org/x/sys/unix"
|
||||
|
||||
|
@ -24,7 +25,15 @@ func moveCursorUp(wr io.Writer, fd uintptr) func(io.Writer, uintptr, int) {
|
|||
// canUpdateStatus returns true if status lines can be printed, the process
|
||||
// output is not redirected to a file or pipe.
|
||||
func canUpdateStatus(fd uintptr) bool {
|
||||
return isatty.IsTerminal(fd)
|
||||
if !isatty.IsTerminal(fd) {
|
||||
return false
|
||||
}
|
||||
term := os.Getenv("TERM")
|
||||
if term == "" {
|
||||
return false
|
||||
}
|
||||
// TODO actually read termcap db and detect if terminal supports what we need
|
||||
return term != "dumb"
|
||||
}
|
||||
|
||||
// getTermSize returns the dimensions of the given terminal.
|
||||
|
|
Loading…
Reference in a new issue