mirror of https://github.com/chzyer/readline.git
[terminal] fix when only stderr is tty (1>/dev/null)
This commit is contained in:
parent
b411b0f4b2
commit
3717d7c383
|
@ -44,7 +44,11 @@ func getWidth(stdoutFd int) int {
|
|||
}
|
||||
|
||||
func GetScreenWidth() int {
|
||||
return getWidth(syscall.Stdout)
|
||||
w := getWidth(syscall.Stdout)
|
||||
if w < 0 {
|
||||
w = getWidth(syscall.Stderr)
|
||||
}
|
||||
return w
|
||||
}
|
||||
|
||||
// ClearScreen clears the console screen
|
||||
|
@ -53,7 +57,7 @@ func ClearScreen(w io.Writer) (int, error) {
|
|||
}
|
||||
|
||||
func DefaultIsTerminal() bool {
|
||||
return IsTerminal(syscall.Stdin) && IsTerminal(syscall.Stdout)
|
||||
return IsTerminal(syscall.Stdin) && (IsTerminal(syscall.Stdout) || IsTerminal(syscall.Stderr))
|
||||
}
|
||||
|
||||
func GetStdin() int {
|
||||
|
|
Loading…
Reference in New Issue