From e73c6921fd8b6e671c51039ea8f1fd2cfbe4d177 Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Fri, 8 Nov 2024 11:44:10 -0700 Subject: [PATCH] progress: Detect tty with std::io::IsTerminal, remove atty Fixes https://github.com/advisories/GHSA-g98v-hv3f-hcfr. --- Cargo.lock | 1 - Cargo.toml | 1 - src/progress/mod.rs | 4 +++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 64e1bc8..fe2e407 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -234,7 +234,6 @@ version = "0.5.0-pre" dependencies = [ "async-stream", "async-trait", - "atty", "clap", "clap_complete", "clicolors-control", diff --git a/Cargo.toml b/Cargo.toml index 71c66ce..c23670c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,6 @@ edition = "2021" [dependencies] async-stream = "0.3.5" async-trait = "0.1.68" -atty = "0.2" clap = { version = "4.3", features = ["derive"] } clap_complete = "4.3" clicolors-control = "1" diff --git a/src/progress/mod.rs b/src/progress/mod.rs index a1330f9..0bcce33 100644 --- a/src/progress/mod.rs +++ b/src/progress/mod.rs @@ -7,6 +7,8 @@ pub mod plain; pub mod spinner; +use std::io::IsTerminal; + use async_trait::async_trait; use tokio::sync::mpsc::{self, UnboundedReceiver as TokioReceiver, UnboundedSender as TokioSender}; @@ -90,7 +92,7 @@ pub enum LineStyle { impl SimpleProgressOutput { pub fn new(verbose: bool) -> Self { - let tty = atty::is(atty::Stream::Stdout); + let tty = std::io::stdout().is_terminal(); if verbose || !tty { Self::Plain(PlainOutput::new())