Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Disable terminal colorization if TERM=dumb is set #320

Merged
merged 2 commits into from
May 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down Expand Up @@ -432,3 +434,12 @@ 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.

if let Ok("dumb") = env::var("TERM").as_deref() {
colored::control::set_override(false)
}
}