summaryrefslogtreecommitdiffstats
path: root/vendor/is-terminal
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/is-terminal')
-rw-r--r--vendor/is-terminal/.cargo-checksum.json2
-rw-r--r--vendor/is-terminal/Cargo.toml4
-rw-r--r--vendor/is-terminal/src/lib.rs52
3 files changed, 36 insertions, 22 deletions
diff --git a/vendor/is-terminal/.cargo-checksum.json b/vendor/is-terminal/.cargo-checksum.json
index 0ee665981..3f4089f37 100644
--- a/vendor/is-terminal/.cargo-checksum.json
+++ b/vendor/is-terminal/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.toml":"66d1f0c7750bdccaddfb640efd98eaab478847f43db9bb61081e009c3f7327a8","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","LICENSE-MIT-atty":"bab426a663ce3d5bbbcea9cdc300da74e94d76c3c79e46699a953f967a08e533","README.md":"bb23e10d4801dee704d2743631e3ca9de6af95761c649e9bd79d62f2df838c9d","src/lib.rs":"eee9f49135fa9f3c24a0e09d0e74a5d5a9f383951dc95c8b08f511102364eb1d"},"package":"21b6b32576413a8e69b90e952e4a026476040d81017b80445deda5f2d3921857"} \ No newline at end of file
+{"files":{"Cargo.toml":"bb97cdfa500859503cfff7a64cda807cb4d4894aa4d52ec6fd831177fb0e7ed3","LICENSE-MIT":"23f18e03dc49df91622fe2a76176497404e46ced8a715d9d2b67a7446571cca3","LICENSE-MIT-atty":"bab426a663ce3d5bbbcea9cdc300da74e94d76c3c79e46699a953f967a08e533","README.md":"bb23e10d4801dee704d2743631e3ca9de6af95761c649e9bd79d62f2df838c9d","src/lib.rs":"79b159d574dd9bc81473b4b694cded6deab0d65abf673176c17fc1146d36abeb"},"package":"256017f749ab3117e93acb91063009e1f1bb56d03965b14c2c8df4eb02c524d8"} \ No newline at end of file
diff --git a/vendor/is-terminal/Cargo.toml b/vendor/is-terminal/Cargo.toml
index b195f11d0..986cfed09 100644
--- a/vendor/is-terminal/Cargo.toml
+++ b/vendor/is-terminal/Cargo.toml
@@ -13,7 +13,7 @@
edition = "2018"
rust-version = "1.48"
name = "is-terminal"
-version = "0.4.4"
+version = "0.4.6"
authors = [
"softprops <d.tangren@gmail.com>",
"Dan Gohman <dev@sunfishcode.online>",
@@ -48,7 +48,7 @@ version = "0.2.14"
version = "0.2.110"
[target."cfg(not(any(windows, target_os = \"hermit\", target_os = \"unknown\")))".dependencies.rustix]
-version = "0.36.4"
+version = "0.37.0"
features = ["termios"]
[target."cfg(target_os = \"hermit\")".dependencies.hermit-abi]
diff --git a/vendor/is-terminal/src/lib.rs b/vendor/is-terminal/src/lib.rs
index 18d41e14d..e363f14c1 100644
--- a/vendor/is-terminal/src/lib.rs
+++ b/vendor/is-terminal/src/lib.rs
@@ -31,11 +31,14 @@
use io_lifetimes::AsFilelike;
#[cfg(windows)]
use io_lifetimes::BorrowedHandle;
+#[cfg(target_os = "hermit")]
+use std::os::hermit::io::AsRawFd;
#[cfg(windows)]
use std::os::windows::io::AsRawHandle;
#[cfg(windows)]
use windows_sys::Win32::Foundation::HANDLE;
+/// Extension trait to check whether something is a terminal.
pub trait IsTerminal {
/// Returns true if this is a terminal.
///
@@ -51,6 +54,23 @@ pub trait IsTerminal {
fn is_terminal(&self) -> bool;
}
+/// Returns `true` if `this` is a terminal.
+///
+/// This is equivalent to calling `this.is_terminal()` and exists only as a
+/// convenience to calling the trait method [`IsTerminal::is_terminal`]
+/// without importing the trait.
+///
+/// # Example
+///
+/// ```
+/// if is_terminal::is_terminal(&std::io::stdout()) {
+/// println!("stdout is a terminal")
+/// }
+/// ```
+pub fn is_terminal<T: IsTerminal>(this: &T) -> bool {
+ this.is_terminal()
+}
+
#[cfg(not(target_os = "unknown"))]
impl<Stream: AsFilelike> IsTerminal for Stream {
#[inline]
@@ -62,7 +82,7 @@ impl<Stream: AsFilelike> IsTerminal for Stream {
#[cfg(target_os = "hermit")]
{
- hermit_abi::isatty(self.as_filelike().as_fd())
+ hermit_abi::isatty(self.as_filelike().as_raw_fd())
}
#[cfg(windows)]
@@ -291,34 +311,28 @@ mod tests {
#[test]
#[cfg(any(unix, target_os = "wasi"))]
fn stdin() {
- unsafe {
- assert_eq!(
- atty::is(atty::Stream::Stdin),
- rustix::io::stdin().is_terminal()
- )
- }
+ assert_eq!(
+ atty::is(atty::Stream::Stdin),
+ rustix::io::stdin().is_terminal()
+ )
}
#[test]
#[cfg(any(unix, target_os = "wasi"))]
fn stdout() {
- unsafe {
- assert_eq!(
- atty::is(atty::Stream::Stdout),
- rustix::io::stdout().is_terminal()
- )
- }
+ assert_eq!(
+ atty::is(atty::Stream::Stdout),
+ rustix::io::stdout().is_terminal()
+ )
}
#[test]
#[cfg(any(unix, target_os = "wasi"))]
fn stderr() {
- unsafe {
- assert_eq!(
- atty::is(atty::Stream::Stderr),
- rustix::io::stderr().is_terminal()
- )
- }
+ assert_eq!(
+ atty::is(atty::Stream::Stderr),
+ rustix::io::stderr().is_terminal()
+ )
}
#[test]