Author: miguel
Date: 2007-12-27 10:51:50 -0500 (Thu, 27 Dec 2007)
New Revision: 91946

Modified:
   trunk/mcs/mcs/ChangeLog
   trunk/mcs/mcs/report.cs
Log:
2007-12-27  Miguel de Icaza  <[EMAIL PROTECTED]>

        * report.cs: Do not use colors if stdout and stderr are not a
        terminal.

Modified: trunk/mcs/mcs/ChangeLog
===================================================================
--- trunk/mcs/mcs/ChangeLog     2007-12-27 15:47:18 UTC (rev 91945)
+++ trunk/mcs/mcs/ChangeLog     2007-12-27 15:51:50 UTC (rev 91946)
@@ -1,3 +1,8 @@
+2007-12-27  Miguel de Icaza  <[EMAIL PROTECTED]>
+
+       * report.cs: Do not use colors if stdout and stderr are not a
+       terminal.
+
 2007-12-27  Marek Safar  <[EMAIL PROTECTED]>
 
        A fix for bug #346998

Modified: trunk/mcs/mcs/report.cs
===================================================================
--- trunk/mcs/mcs/report.cs     2007-12-27 15:47:18 UTC (rev 91945)
+++ trunk/mcs/mcs/report.cs     2007-12-27 15:51:50 UTC (rev 91946)
@@ -465,7 +465,19 @@
                sealed class ErrorMessage : AbstractMessage
                {
                        static string prefix, postfix;
+
+                       [System.Runtime.InteropServices.DllImport ("libc", 
EntryPoint="isatty")]
+                       extern static int _isatty (int fd);
                        
+                       static bool isatty (int fd)
+                       {
+                               try {
+                                       return _isatty (fd) == 1;
+                               } catch {
+                                       return false;
+                               }
+                       }
+                       
                        static ErrorMessage ()
                        {
                                string term = 
Environment.GetEnvironmentVariable ("TERM");
@@ -484,6 +496,12 @@
                                        xterm_colors = true;
                                        break;
                                }
+                               if (!xterm_colors)
+                                       return;
+
+                               if (!(isatty (1) && isatty (2)))
+                                       return;
+                               
                                string config = 
Environment.GetEnvironmentVariable ("MCS_COLORS");
                                if (config == null){
                                        config = "errors=red";
@@ -498,9 +516,6 @@
 
                                config = config.Substring (7);
                                
-                               if (!xterm_colors)
-                                       return;
-
                                int p = config.IndexOf (",");
                                if (p == -1)
                                        prefix = GetForeground (config);

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to