Added terminal detection

This commit is contained in:
Eduard Urbach 2024-03-12 00:25:20 +01:00
parent 929938dcd6
commit 71c74c800b
Signed by: eduard
GPG key ID: 49226B848C78F6C8
12 changed files with 37 additions and 79 deletions

6
tty/Terminal_darwin.go Normal file
View file

@ -0,0 +1,6 @@
package tty
// IsTerminal returns true if the file descriptor is a terminal.
func IsTerminal(fd uintptr) bool {
return false
}

9
tty/Terminal_linux.go Normal file
View file

@ -0,0 +1,9 @@
package tty
import "golang.org/x/sys/unix"
// IsTerminal returns true if the file descriptor is a terminal.
func IsTerminal(fd uintptr) bool {
_, err := unix.IoctlGetTermios(int(fd), unix.TCGETS)
return err == nil
}

6
tty/Terminal_windows.go Normal file
View file

@ -0,0 +1,6 @@
package tty
// IsTerminal returns true if the file descriptor is a terminal.
func IsTerminal(fd uintptr) bool {
return false
}