Code refactoring after #1141

This commit is contained in:
Alex X
2024-05-28 13:21:33 +03:00
parent cc74504ed8
commit a6b9b4993f
5 changed files with 28 additions and 55 deletions
-7
View File
@@ -1,7 +0,0 @@
//go:build !unix && !windows
package shell
func IsInteractive(fd uintptr) bool {
return false
}
-10
View File
@@ -1,10 +0,0 @@
//go:build unix
package shell
import "golang.org/x/sys/unix"
func IsInteractive(fd uintptr) bool {
_, err := unix.IoctlGetTermios(int(fd), unix.TIOCGETA)
return err == nil
}
-19
View File
@@ -1,19 +0,0 @@
//go:build windows
package shell
import (
"syscall"
"unsafe"
)
var (
kernel32 = syscall.NewLazyDLL("kernel32.dll")
procGetConsoleMode = kernel32.NewProc("GetConsoleMode")
)
func IsInteractive(fd uintptr) bool {
var st uint32
r, _, e := syscall.Syscall(procGetConsoleMode.Addr(), 2, fd, uintptr(unsafe.Pointer(&st)), 0)
return r != 0 && e == 0
}