Merge pull request #2416 from topecongiro/eshell

Explicitly disable colored output when it is not supported
This commit is contained in:
Nick Cameron 2018-02-06 21:22:18 +13:00 committed by GitHub
commit fe06b96f48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -615,7 +615,13 @@ pub fn format_input<T: Write>(
));
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());