Color/color_unix.go
2025-06-06 13:51:43 -05:00

34 lines
518 B
Go

//go:build !windows
// +build !windows
package color
import (
"os"
"syscall"
"unsafe"
)
const ioctlReadTermios = 0x5401
// isTerminal checks if the file is a terminal
func isTerminal(f *os.File) bool {
fd := f.Fd()
var termios syscall.Termios
r1, _, errno := syscall.Syscall6(
syscall.SYS_IOCTL,
fd,
ioctlReadTermios,
uintptr(unsafe.Pointer(&termios)),
0, 0, 0,
)
return r1 == 0 && errno == 0
}
// isWindowsTerminal always returns false on Unix
func isWindowsTerminal() bool {
return false
}