function _drush_bootstrap_output_prepare

8.0.x bootstrap.inc _drush_bootstrap_output_prepare()
6.x bootstrap.inc _drush_bootstrap_output_prepare()
7.x bootstrap.inc _drush_bootstrap_output_prepare()
5.x bootstrap.inc _drush_bootstrap_output_prepare()
master bootstrap.inc _drush_bootstrap_output_prepare()
1 call to _drush_bootstrap_output_prepare()

File

includes/bootstrap.inc, line 530
Drush bootstrapping code.

Code

function _drush_bootstrap_output_prepare() {
  $backend = drush_set_context('DRUSH_BACKEND', drush_get_option('backend'));

  // Pipe implies quiet.
  $quiet = drush_set_context('DRUSH_QUIET', drush_get_option(array('quiet', 'pipe')));

  drush_set_context('DRUSH_PIPE', drush_get_option('pipe'));

  if ($backend) {
    // Load options passed as a JSON encoded string through STDIN.
    $stdin_options = _drush_backend_get_stdin();
    if (is_array($stdin_options)) {
      drush_set_context('stdin', $stdin_options);
    }
    // Add an output buffer handler to collect output/pass through backend
    // packets. Using a chunksize of 2 ensures that each line is flushed
    // straight away.
    if ($quiet) {
      // Pass through of backend packets, discard regular output.
      ob_start('drush_backend_output_discard', 2);
    }
    else {
      // Collect output.
      ob_start('drush_backend_output_collect', 2);
    }
  }

  // In non-backend quiet mode we start buffering and discards it on command
  // completion.
  if ($quiet && !$backend) {
    ob_start();
  }
}