/*
 * Copyright 2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.gradle.internal.console;

public class UnixConsoleMetaData implements ConsoleMetaData {
    public int getCols() {
        final String width = System.getenv("COLUMNS");
        try{
            return Integer.parseInt(width);
        }catch(NumberFormatException ex){
            return 0;
        }
    }
}

@@ -648,16 +648,74 @@
 nsole;%0A%0A
+import org.slf4j.Logger;%0Aimport org.slf4j.LoggerFactory;%0A%0A
 public c
@@ -768,16 +768,110 @@
 aData %7B%0A
+%0A    public static final Logger LOGGER = LoggerFactory.getLogger(UnixConsoleMetaData.class);%0A%0A
     publ
@@ -910,21 +910,23 @@
  String 
-width
+columns
  = Syste
@@ -946,16 +946,51 @@
 UMNS%22);%0A
+        if (columns != null) %7B%0A    
         
@@ -992,18 +992,23 @@
      try
+ 
 %7B%0A
+    
         
@@ -1039,13 +1039,15 @@
 Int(
-width
+columns
 );%0A 
@@ -1057,14 +1057,20 @@
     
+ 
-%7D
+   %7D 
 catch
+ 
 (Num
@@ -1091,16 +1091,17 @@
 tion ex)
+ 
 %7B%0A      
@@ -1110,27 +1110,155 @@
     
+   
-return 0;%0A        %7D
+ LOGGER.debug(%22Cannot parse COLUMNS environment variable to get console width. Value: '%25s'%22, columns);%0A            %7D%0A        %7D%0A        return 0;
 %0A   

Add Null check and give decent debug message if COLUMN env var cannot be parsed.