As of Rust 1.70, most users should use the
IsTerminal trait in the Rust
standard library instead of this crate.
is-terminal is a simple utility that answers one question:
Is this a terminal?
A "terminal", also known as a "tty", is an I/O device which may be interactive and may support color and other special features. This crate doesn't provide any of those features; it just answers this one question.
On Unix-family platforms, this is effectively the same as the
function for testing whether a given stream is a terminal, though it accepts
high-level stream types instead of raw file descriptors.
On Windows, it uses a variety of techniques to determine whether the given stream is a terminal.
This crate is derived from the atty crate with PR #51 bug fix and PR #54 port to windows-sys applied. The only additional difference is that the atty crate only accepts stdin, stdout, or stderr, while this crate accepts any stream. In particular, this crate does not access any stream that is not passed to it, in accordance with I/O safety.
This library is tested on both Unix-family and Windows platforms.
To test it on a platform manually, use the provided
stdio example program.
When run normally, it prints this:
To test stdin, pipe some text to the program:
To test stdout, pipe the program to something:
To test stderr, pipe the program to something redirecting stderr:
Minimum Supported Rust Version (MSRV)
This crate currently works on the version of Rust on Debian stable, which is currently Rust 1.63. This policy may change in the future, in minor version releases, so users using a fixed version of Rust should pin to a specific version of this crate.