tag | 57cfa22730dc07b3f6e956f84bf8b9eb1d940fdf | |
---|---|---|
tagger | The Android Open Source Project <initial-contribution@android.com> | Mon Apr 15 11:23:06 2024 -0700 |
object | 0caa7384fd30277fbe2a53b2d9f2684951409d1e |
Android 14.0.0 Release 33 (AP1A.240405.002.B1)
commit | 0caa7384fd30277fbe2a53b2d9f2684951409d1e | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Tue Nov 21 00:10:22 2023 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Tue Nov 21 00:10:22 2023 +0000 |
tree | 8a2f8ca02a855a7e6380a49522514fc34d302757 | |
parent | d41aecf6d3e56ebc44ff9ddd623dbd9be691d589 [diff] | |
parent | 4ea1424c923562895ab5f32af0d2fb128e19e2c8 [diff] |
Snap for 11124398 from 4ea1424c923562895ab5f32af0d2fb128e19e2c8 to 24Q1-release Change-Id: Iaae87f835f1bf29074a15ce479ee3cf1fa1f022e
are you or are you not a tty?
Add the following to your Cargo.toml
[dependencies] atty = "0.2"
use atty::Stream; fn main() { if atty::is(Stream::Stdout) { println!("I'm a terminal"); } else { println!("I'm not"); } }
This library has been unit tested on both unix and windows platforms (via appveyor).
A simple example program is provided in this repo to test various tty's. By default.
It prints
$ cargo run --example atty stdout? true stderr? true stdin? true
To test std in, pipe some text to the program
$ echo "test" | cargo run --example atty stdout? true stderr? true stdin? false
To test std out, pipe the program to something
$ cargo run --example atty | grep std stdout? false stderr? true stdin? true
To test std err, pipe the program to something redirecting std err
$ cargo run --example atty 2>&1 | grep std stdout? false stderr? false stdin? true
Doug Tangren (softprops) 2015-2019