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

Commit

Permalink
Merge #320
Browse files Browse the repository at this point in the history
320: Disable terminal colorization if `TERM=dumb` is set r=jonas-schievink a=Urhengulas

This PR fixes the problem `@fhars` described in #318:
> The current version of the colored crate ignores the capabilities of the terminal (see colored-rs/colored#108), which makes the outupt of probe-run unparseable in e.g. emacs compilation mode.

It also supersedes #318 as a fix to the problem. The reason for not going with #318 is that it adds the `terminfo` crate as a dependency which seems unmaintained and with many outdated dependencies.

Co-authored-by: Urhengulas <[email protected]>
  • Loading branch information
bors[bot] and Urhengulas authored May 9, 2022
2 parents 5342459 + e17f156 commit 4c71afb
Showing 1 changed file with 11 additions and 0 deletions.
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)
}
}

0 comments on commit 4c71afb

Please sign in to comment.