Skip to content
Myr

Don't output colours by default if TERM=dumb or NO_COLOR=1

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This matches ZFS, and is mostly état d'art Closes #542

authored by наб · committed by наб · parent 94cda2e · Browse files · 1 file+9 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−1 removed

  • other:+9 added−1 removed

1 file+9 added−1 removed

modified:src/options.rs+9 added-1 removed
1use std::fs::File;2use std::path::PathBuf;3use std::process::{Command, Stdio};4use std::{cmp, fmt, io};4use std::{cmp, env, fmt, io};56use anyhow::ensure;7use atty::Stream;8use clap::ArgMatches;
288 unmodified lines
297 if options.command_output_policy == CommandOutputPolicy::Inherit298 || !atty::is(Stream::Stdout)299 {300 OutputStyleOption::Basic301 } else if !(env::var_os("TERM")302 .map(|t| t != "unknown" && t != "dumb")303 .unwrap_or(false)304 && env::var_os("NO_COLOR")305 .map(|t| t.is_empty())306 .unwrap_or(true))307 {308 OutputStyleOption::NoColor309 } else {310 OutputStyleOption::Full311 }312 }
95 unmodified lines