Mojo function
isatty
isatty(fd: Int) -> Bool
Checks whether a file descriptor refers to a terminal.
Returns True if the file descriptor fd is open and connected to a
tty(-like) device, otherwise False. On GPUs, the function always returns
False.
Examples:
from os import isatty
# Check if stdout (fd=1) is a terminal
if isatty(1):
print("Running in a terminal")
else:
print("Output is redirected")Args:
- fd (
Int): A file descriptor.
Returns:
Bool: True if fd is connected to a terminal, False otherwise.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!