From 4fcb1b2202b97c5a21894672232700225223a138 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Mon, 5 Jun 2023 20:00:46 +0200 Subject: [PATCH] cli: replace atty with std::io::IsTerminal The `atty` crate is unmaintained[1] and `std::io::IsTerminal` was stabilized in Rust 1.70. [1]: https://rustsec.org/advisories/RUSTSEC-2021-0145.html PR #2526 --- .github/workflows/ci.yml | 2 +- Cargo.lock | 21 --------------------- README.md | 2 +- crates/cli/Cargo.toml | 1 - crates/cli/src/lib.rs | 8 +++++--- 5 files changed, 7 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 39a6de4..63c1061 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -43,7 +43,7 @@ jobs: include: - build: pinned os: ubuntu-22.04 - rust: 1.65.0 + rust: 1.70.0 - build: stable os: ubuntu-22.04 rust: stable diff --git a/Cargo.lock b/Cargo.lock index 9b70ec0..44bb161 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,17 +20,6 @@ dependencies = [ "memchr", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi", - "libc", - "winapi", -] - [[package]] name = "base64" version = "0.20.0" @@ -171,7 +160,6 @@ dependencies = [ name = "grep-cli" version = "0.1.7" dependencies = [ - "atty", "bstr", "globset", "lazy_static", @@ -240,15 +228,6 @@ dependencies = [ "regex", ] -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "ignore" version = "0.4.20" diff --git a/README.md b/README.md index 8447f10..9fc2728 100644 --- a/README.md +++ b/README.md @@ -343,7 +343,7 @@ $ pkgman install ripgrep_x86 If you're a **Rust programmer**, ripgrep can be installed with `cargo`. -* Note that the minimum supported version of Rust for ripgrep is **1.65.0**, +* Note that the minimum supported version of Rust for ripgrep is **1.70.0**, although ripgrep may work with older versions. * Note that the binary may be bigger than expected because it contains debug symbols. This is intentional. To remove debug symbols and therefore reduce diff --git a/crates/cli/Cargo.toml b/crates/cli/Cargo.toml index 27e7edd..d9cc344 100644 --- a/crates/cli/Cargo.toml +++ b/crates/cli/Cargo.toml @@ -14,7 +14,6 @@ license = "Unlicense OR MIT" edition = "2018" [dependencies] -atty = "0.2.11" bstr = "1.1.0" globset = { version = "0.4.10", path = "../globset" } lazy_static = "1.1.0" diff --git a/crates/cli/src/lib.rs b/crates/cli/src/lib.rs index e54893b..53b4d2c 100644 --- a/crates/cli/src/lib.rs +++ b/crates/cli/src/lib.rs @@ -165,6 +165,8 @@ mod pattern; mod process; mod wtr; +use std::io::IsTerminal; + pub use crate::decompress::{ resolve_binary, DecompressionMatcher, DecompressionMatcherBuilder, DecompressionReader, DecompressionReaderBuilder, @@ -215,7 +217,7 @@ pub fn is_readable_stdin() -> bool { /// Returns true if and only if stdin is believed to be connected to a tty /// or a console. pub fn is_tty_stdin() -> bool { - atty::is(atty::Stream::Stdin) + std::io::stdin().is_terminal() } /// Returns true if and only if stdout is believed to be connected to a tty @@ -227,11 +229,11 @@ pub fn is_tty_stdin() -> bool { /// implementations of `ls` will often show one item per line when stdout is /// redirected, but will condensed output when printing to a tty. pub fn is_tty_stdout() -> bool { - atty::is(atty::Stream::Stdout) + std::io::stdout().is_terminal() } /// Returns true if and only if stderr is believed to be connected to a tty /// or a console. pub fn is_tty_stderr() -> bool { - atty::is(atty::Stream::Stderr) + std::io::stderr().is_terminal() }