From db0644c985832863a891360a45b7028c0ceca33d Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Thu, 9 Oct 2008 00:49:53 +0000 Subject: [PATCH] BUGFIX: Improved detection of CLI colour support git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63927 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- dev/SSCli.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dev/SSCli.php b/dev/SSCli.php index 23f3bec7a..1f504c71c 100644 --- a/dev/SSCli.php +++ b/dev/SSCli.php @@ -5,6 +5,10 @@ * Support less-trivial output stuff such as colours (on xterm-color) */ class SSCli extends Object { + static function supports_colour() { + return posix_isatty(STDOUT); + } + /** * Return text encoded for CLI output, optionally coloured * @param string $fgColour The foreground colour - black, red, green, yellow, blue, magenta, cyan, white. Null is default. @@ -12,7 +16,7 @@ class SSCli extends Object { * @param string $bold A boolean variable - bold or not. */ static function text($text, $fgColour = null, $bgColour = null, $bold = false) { - if(!isset($_SERVER['TERM']) || $_SERVER['TERM'] != 'xterm-color') return $text; + if(!self::supports_colour()) return $text; $colours = array( 'black' => 0,