Package `term` provides support functions for dealing with terminals, cross-compatible with Unix,darwin and windows. The low leve const `unix.TCGETS` is not defined in Darwin arch, ad prevent shspiper to buil and run on osx
17 lines
286 B
Go
17 lines
286 B
Go
package plugin
|
|
|
|
import (
|
|
"golang.org/x/term"
|
|
"io"
|
|
"os"
|
|
)
|
|
|
|
// checkIfTerminal returns whether the given file descriptor is a terminal.
|
|
func checkIfTerminal(w io.Writer) bool {
|
|
switch v := w.(type) {
|
|
case *os.File:
|
|
return term.IsTerminal(int(v.Fd()))
|
|
default:
|
|
return false
|
|
}
|
|
}
|