function drush_build_drush_command

8.0.x environment.inc drush_build_drush_command($drush_path = NULL, $php = NULL, $os = NULL, $remote_command = FALSE, $environment_variables = array())
6.x environment.inc drush_build_drush_command($drush_path = NULL, $php = NULL, $os = NULL, $remote_command = FALSE)
7.x environment.inc drush_build_drush_command($drush_path = NULL, $php = NULL, $os = NULL, $remote_command = FALSE, $environment_variables = array())
5.x environment.inc drush_build_drush_command($drush_path = NULL, $php = NULL, $os = NULL, $remote_command = FALSE)
master environment.inc drush_build_drush_command($drush_path = NULL, $php = NULL, $os = NULL, $remote_command = FALSE, $environment_variables = array())

Build a drush command suitable for use for drush to call itself e.g. in backend_invoke.

1 call to drush_build_drush_command()
drush_backend_invoke_concurrent in includes/backend.inc
Execute a new local or remote command in a new process.

File

includes/environment.inc, line 580
Functions used by drush to query the environment and setting the current configuration.

Code

function drush_build_drush_command($drush_path = NULL, $php = NULL, $os = NULL, $remote_command = FALSE) {
  $os = _drush_get_os($os);
  $additional_options = '';
  if (is_null($drush_path)) {
    if (!$remote_command) {
      $drush_path = DRUSH_COMMAND;
    }
    else {
      $drush_path = drush_is_windows($os) ? 'drush.bat' : 'drush';
    }
  }
  // If the path to drush points to drush.php, then we will need to
  // run it via php rather than direct execution.  By default, we
  // will use 'php' unless something more specific was passed in
  // via the --php flag.
  if (substr($drush_path, -4) == ".php") {
    if (!isset($php)) {
      $php = drush_get_option('php');
      if (!isset($php)) {
        $php = 'php';
      }
    }
    if (isset($php) && ($php != "php")) {
      $additional_options .= ' --php=' . drush_escapeshellarg($php, $os);
    }
    // We will also add in the php options from --php-options
    $php = drush_escapeshellarg($php, $os) . ' ';
    $php_options = drush_get_option('php-options', '');
    if (!empty($php_options)) {
      $php .= $php_options . ' ';
      $additional_options .= ' --php-options=' . drush_escapeshellarg($php_options, $os);
    }
  }
  else {
    $php = '';
  }
  return $php . drush_escapeshellarg($drush_path, $os) . $additional_options;
}