Comment by skydhash
4 days ago
There’s a function isatty that detect if a file descriptor (stdout is one) is associated with a terminal
https://man.openbsd.org/man3/ttyname.3
I believe most standard libraries has a version.
4 days ago
There’s a function isatty that detect if a file descriptor (stdout is one) is associated with a terminal
https://man.openbsd.org/man3/ttyname.3
I believe most standard libraries has a version.
I was about to comment the same thing. Usually I don't call the function directly, but via the tty command in my shell scripts:
Now I wonder how _isatty_ itself detects whether a file descriptor is associated with a terminal!
In OpenBSD, with the fcntl system call
https://github.com/openbsd/src/blob/master/lib/libc/gen/isat...
https://man.openbsd.org/fcntl
https://github.com/openbsd/src/blob/master/sys/sys/fcntl.h
https://github.com/openbsd/src/blob/ba496e5267528b649ec87212...
https://github.com/openbsd/src/blob/ba496e5267528b649ec87212...