From 7f949a5018d77922891e12f134651590e6e78a6e Mon Sep 17 00:00:00 2001 From: topecongiro Date: Tue, 6 Feb 2018 09:29:00 +0900 Subject: [PATCH] Explicitly disable colored output when it is not supported --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 2b89bde72c1..db05a24f979 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -615,7 +615,13 @@ pub fn format_input( )); Handler::with_emitter(true, false, silent_emitter) } else { - Handler::with_tty_emitter(ColorConfig::Auto, true, false, Some(codemap.clone())) + let supports_color = term::stderr().map_or(false, |term| term.supports_color()); + let color_cfg = if supports_color { + ColorConfig::Auto + } else { + ColorConfig::Never + }; + Handler::with_tty_emitter(color_cfg, true, false, Some(codemap.clone())) }; let mut parse_session = ParseSess::with_span_handler(tty_handler, codemap.clone());