tag | dbd4cf590f47bd15b5d68cf8c86f2c2268f65d20 | |
---|---|---|
tagger | The Android Open Source Project <initial-contribution@android.com> | Tue Dec 14 06:55:58 2021 -0800 |
object | 670197b0e600fd0290a3e89f67ebd5071af6b445 |
Android 12.0.0 release 18
commit | 670197b0e600fd0290a3e89f67ebd5071af6b445 | [log] [tgz] |
---|---|---|
author | Bob Badour <bbadour@google.com> | Tue Mar 23 15:14:59 2021 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Tue Mar 23 15:14:59 2021 +0000 |
tree | 505dc9520d1851452ff862429424cff9418e96d0 | |
parent | e41109e02fd052be5dd6a4a264cd203bbf65410d [diff] | |
parent | 8558412c300a9668c74c33369273788bff112c60 [diff] |
[LSC] Add LOCAL_LICENSE_KINDS to external/rust/crates/atty am: 0712eb581a am: 3747204276 am: 8558412c30 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/atty/+/1649592 Change-Id: Ibb12b7080ea794278fa2764f5a116f14e465c0ae
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