isatty_bsd.go 609 B

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