Index: includes/environment.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/environment.inc,v
retrieving revision 1.36
diff -u -p -r1.36 environment.inc
--- includes/environment.inc	4 Jun 2009 19:48:55 -0000	1.36
+++ includes/environment.inc	28 Sep 2009 09:54:57 -0000
@@ -377,9 +377,14 @@ function _drush_bootstrap_drush() {
   register_shutdown_function('drush_shutdown');
 
   // Attempt to set the screen width to the current screen width.
-  // This will only work if the user has exported COLUMNS in his session.
+  // First we check if the user has exported COLUMNS in the shell session.
   if (!($columns = getenv('COLUMNS'))) {
-    $columns = 80;
+    // If COLUMNS has not been exported, we try the stty command.
+    exec('stty size 2>&1', $stty_output, $stty_status);
+    if (!$stty_status) $columns = preg_replace('/\d+\s(\d+)/', '$1', $stty_output[0], -1, $stty_count);
+    // If stty failed, probably because we're running under Windows, we assume 80 columns.
+    // Same goes if we failed to parse the output from stty.
+    if ($stty_status || !$stty_count) $columns = 80;
   }
   drush_set_context('DRUSH_COLUMNS', $columns);
 
