? includes/table.inc
Index: includes/drush.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/drush/includes/drush.inc,v
retrieving revision 1.174
diff -u -p -r1.174 drush.inc
--- includes/drush.inc	24 Dec 2010 05:10:29 -0000	1.174
+++ includes/drush.inc	25 Dec 2010 05:57:28 -0000
@@ -638,12 +638,23 @@ function drush_table_column_autowidth($r
  *   Full path to a file.
  */
 function drush_print_file($file) {
+  // Don't even bother to print the file in --no mode
+  if (drush_get_context('DRUSH_NEGATIVE')) {
+    return;
+  }
   if ((substr($file,-4) == ".htm") || (substr($file,-5) == ".html")) {
     $tmp_file = drush_tempnam(basename($file));
     file_put_contents($tmp_file, drush_html_to_text(file_get_contents($file)));
     $file = $tmp_file;
   }
-  if (drush_shell_exec_interactive("less %s", $file)) {
+  // Do not wait for user input in --yes or --pipe modes
+  if (drush_get_context('DRUSH_PIPE')) {
+    drush_print_pipe(file_get_contents($file));
+  }
+  elseif (drush_get_context('DRUSH_AFFIRMATIVE')) {
+    drush_print(file_get_contents($file));
+  }
+  elseif (drush_shell_exec_interactive("less %s", $file)) {
     return;
   }
   elseif (drush_shell_exec_interactive("more %s", $file)) {
@@ -754,9 +765,22 @@ function drush_choice($options, $prompt 
   }
   drush_print_table($rows);
   
-  while ($line = trim(fgets(STDIN))) {
-    if (array_key_exists($line, $selection_list)) {
-      return $selection_list[$line];
+  // We won't allow --yes to subvert the selection process,
+  // but in backend and modes we will return the first option.
+  // Hopefully this will always be the "best choice".  Prompting
+  // the user is undesirable in these modes, though, so we
+  // need to do something to pick a reasonable default.
+  if (drush_get_context('DRUSH_BACKEND') || drush_get_context('DRUSH_PIPE')) {
+    return $selection_list[1];
+  }
+  
+  // If the user specified --no, then cancel; otherwise,
+  // wait for user input and return the selected result.
+  if (!drush_get_context('DRUSH_NEGATIVE')) {
+    while ($line = trim(fgets(STDIN))) {
+      if (array_key_exists($line, $selection_list)) {
+	return $selection_list[$line];
+      }
     }
   }
   drush_print(dt('Cancelled'));
