From 8337da960b705f984ac32aaf23289b8e734a4b3b Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Tue, 18 Sep 2012 18:22:56 +0200 Subject: [PATCH] feature #1353: state is only colored when using a tty --- src/cli/cli_helper.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/cli/cli_helper.rb b/src/cli/cli_helper.rb index 52ee6954cd..570ffd1a24 100644 --- a/src/cli/cli_helper.rb +++ b/src/cli/cli_helper.rb @@ -98,11 +98,15 @@ module CLIHelper BAD_STATES=%w{fail err err} def CLIHelper.color_state(stat) - case stat.strip - when *OK_STATES - ANSI_GREEN+stat+ANSI_RESET - when *BAD_STATES - ANSI_RED+stat+ANSI_RESET + if $stdout.tty? + case stat.strip + when *OK_STATES + ANSI_GREEN+stat+ANSI_RESET + when *BAD_STATES + ANSI_RED+stat+ANSI_RESET + else + stat + end else stat end