isatty_bsd.go 567 B

12345678910111213141516171819
  1. //go:build (darwin || freebsd || openbsd || netbsd || dragonfly) && !appengine
  2. // +build darwin freebsd openbsd netbsd dragonfly
  3. // +build !appengine
  4. package isatty
  5. import "golang.org/x/sys/unix"
  6. // IsTerminal return true if the file descriptor is terminal.
  7. func IsTerminal(fd uintptr) bool {
  8. _, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA)
  9. return err == nil
  10. }
  11. // IsCygwinTerminal return true if the file descriptor is a cygwin or msys2
  12. // terminal. This is also always false on this environment.
  13. func IsCygwinTerminal(fd uintptr) bool {
  14. return false
  15. }