Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsCygwinPty ¶
IsCygwinPty returns true if the file descriptor is a Cygwin/MSYS pty.
Types ¶
type TTYState ¶
type TTYState int
func CheckTTY ¶
func CheckTTY(v interface{}) TTYState
isTTY tries to only return true if the input is actually a terminal.
os.ModeCharDevice isn't quite enough. I tested various OS/shell combos, using the following code:
fi, _ := os.Stdin.Stat() fmt.Println(fi.Mode())
Results:
TTY in Pipe in TTY out Pipe out macOS/bash Dcrw--w---- -prw-rw---- Dcrw--w---- -prw-rw---- macOS/zsh Dcrw--w---- -prw-rw---- Dcrw--w---- -prw-rw---- linux/bash Dcrw--w---- -prw------- Dcrw--w---- -prw------- linux/zsh Dcrw--w---- -prw------- Dcrw--w---- -prw------- linux/fish Dcrw--w---- -prw------- Dcrw--w---- -prw------- win/cmd.exe Dcrw-rw-rw- --rw-rw-rw- Dcrw-rw-rw- --rw-rw-rw- win/powershell Dcrw-rw-rw- --rw-rw-rw- Dcrw-rw-rw- --rw-rw-rw- win/gitbash -prw-rw-rw- -prw-rw-rw- -prw-rw-rw- -prw-rw-rw- win/cygwin -prw-rw-rw- -prw-rw-rw- -prw-rw-rw- -prw-rw-rw-
More info:
Click to show internal directories.
Click to hide internal directories.