install/includes/cli-core.php
changeset 1021 5990ac411f34
parent 1020 0867b9d38c38
child 1081 745200a9cc2a
--- a/install/includes/cli-core.php	Tue Jun 02 13:27:05 2009 -0400
+++ b/install/includes/cli-core.php	Fri Jun 05 22:09:42 2009 -0400
@@ -782,9 +782,16 @@
 
 function parse_shellcolor_string($str)
 {
+  // only compute this once (saves some CPU time)
+  static $do_colors = null;
+  if ( $do_colors === null )
+  {
+    $do_colors = ( isset($_SERVER['TERM']) && $_SERVER['TERM'] != 'dumb' );
+  }
+  
   $expr = '/<c ((?:[0-9]+)(?:;[0-9]+)*)>([\w\W]*?)<\/c>/';
   while ( preg_match($expr, $str) )
-    $str = preg_replace($expr, "\x1B[\\1m\\2\x1B[0m", $str);
+    $str = $do_colors ? preg_replace($expr, "\x1B[\\1m\\2\x1B[0m", $str) : preg_replace($expr, "\\2", $str);
   
   return $str;
 }