From fc2d5f472ed0257e4a969407b505074217e9dfe6 Mon Sep 17 00:00:00 2001 From: Urhengulas Date: Mon, 9 May 2022 12:40:10 +0200 Subject: [PATCH 1/2] Disable terminal colorization if `TERM=dumb` is set --- src/main.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main.rs b/src/main.rs index bb3607cb..1904f47b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -37,6 +37,8 @@ use crate::{backtrace::Outcome, canary::Canary, elf::Elf, target_info::TargetInf const TIMEOUT: Duration = Duration::from_secs(1); fn main() -> anyhow::Result<()> { + configure_terminal_colorization(); + #[allow(clippy::redundant_closure)] cli::handle_arguments().map(|code| process::exit(code)) } @@ -432,3 +434,13 @@ fn setup_logging_channel( fn print_separator() -> io::Result<()> { writeln!(io::stderr(), "{}", "─".repeat(80).dimmed()) } + +fn configure_terminal_colorization() { + // ! This should be detected by `colored`, but currently is not. + // See https://github.com/mackwic/colored/issues/108 and https://github.com/knurling-rs/probe-run/pull/318. + + match env::var("TERM").as_deref() { + Ok("dumb") => colored::control::set_override(false), + _ => {} + } +} From e17f1561bc0f3fdde68f3b0352b988725c42a48c Mon Sep 17 00:00:00 2001 From: Urhengulas Date: Mon, 9 May 2022 14:45:49 +0200 Subject: [PATCH 2/2] Satisfy clippy --- src/main.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 1904f47b..276d17d3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -439,8 +439,7 @@ fn configure_terminal_colorization() { // ! This should be detected by `colored`, but currently is not. // See https://github.com/mackwic/colored/issues/108 and https://github.com/knurling-rs/probe-run/pull/318. - match env::var("TERM").as_deref() { - Ok("dumb") => colored::control::set_override(false), - _ => {} + if let Ok("dumb") = env::var("TERM").as_deref() { + colored::control::set_override(false) } }