Skip to content

Commit

Permalink
Don't output colours by default if TERM=dumb or NO_COLOR=1
Browse files Browse the repository at this point in the history
This matches ZFS, and is mostly état d'art

Closes #542
  • Loading branch information
nabijaczleweli committed Sep 2, 2022
1 parent 94cda2e commit 049d113
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/options.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fs::File;
use std::path::PathBuf;
use std::process::{Command, Stdio};
use std::{cmp, fmt, io};
use std::{cmp, env, fmt, io};

use anyhow::ensure;
use atty::Stream;
Expand Down Expand Up @@ -298,6 +298,14 @@ impl Options {
|| !atty::is(Stream::Stdout)
{
OutputStyleOption::Basic
} else if !(env::var_os("TERM")
.map(|t| t != "unknown" && t != "dumb")
.unwrap_or(false)
&& env::var_os("NO_COLOR")
.map(|t| t.is_empty())
.unwrap_or(true))
{
OutputStyleOption::NoColor
} else {
OutputStyleOption::Full
}
Expand Down

2 comments on commit 049d113

@jtsorlinis
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to have broken colours on Windows

@nabijaczleweli
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.