diff --git a/includes/output.inc b/includes/output.inc index 1c56dc63ef..950953f121 100644 --- a/includes/output.inc +++ b/includes/output.inc @@ -34,12 +34,15 @@ function drush_print($message = '', $indent = 0, $handle = NULL, $newline = TRUE if (($charset = drush_get_option('output_charset')) && function_exists('iconv')) { $msg = iconv('UTF-8', $charset, $msg); } - if (isset($handle)) { - fwrite($handle, $msg); - } - else { - print $msg; - } + if (!isset($handle)) { + $handle = STDOUT; + // In the past, Drush would use `print` here; now that we are using + // fwrite (to avoid problems with php sending the http headers), we + // must explicitly capture the output, because ob_start() / ob_end() + // does not capture output written via fwrite to STDOUT. + drush_backend_output_collect($msg); + } + fwrite($handle, $msg); } /**