function _drush_backend_print_output

8.0.x backend.inc _drush_backend_print_output($output_string, $backend_options)
6.x backend.inc _drush_backend_print_output($output_string, $backend_options)
7.x backend.inc _drush_backend_print_output($output_string, $backend_options)
5.x backend.inc _drush_backend_print_output($output_string, $backend_options)
master backend.inc _drush_backend_print_output($output_string, $backend_options)

Print the output received from a call to backend invoke, adding the label to the head of each line if necessary.

2 calls to _drush_backend_print_output()
_drush_backend_integrate in includes/backend.inc
Integrate log messages and error statuses into the current process.
_drush_backend_proc_open in includes/backend.inc
Call an external command using proc_open.

File

includes/backend.inc, line 515
Drush backend API

Code

function _drush_backend_print_output($output_string, $backend_options) {
  if ($backend_options['output'] && !empty($output_string)) {
    $output_label = array_key_exists('#output-label', $backend_options) ? $backend_options['#output-label'] : FALSE;
    if (!empty($output_label)) {
      // Remove one, and only one newline from the end of the
      // string. Else we'll get an extra 'empty' line.
      foreach (explode("\n", preg_replace('/\\n$/', '', $output_string)) as $line) {
        fwrite(STDOUT, $output_label . rtrim($line) . "\n");
      }
    }
    else {
      fwrite(STDOUT, $output_string);
    }
  }
}