function drush_find_drush

8.0.x environment.inc drush_find_drush()
6.x environment.inc drush_find_drush()
7.x environment.inc drush_find_drush()
3.x environment.inc drush_find_drush()
4.x environment.inc drush_find_drush()
5.x environment.inc drush_find_drush()
master environment.inc drush_find_drush()

Determine a proper way to call drush again

This check if we were called directly or as an argument to some wrapper command (php and sudo are checked now).

Calling ./drush.php directly yields the following environment:

_SERVER["argv"][0] => ./drush.php

Calling php ./drush.php also yields the following:

_SERVER["argv"][0] => ./drush.php

Note that the $_ global is defined only in bash and therefore cannot be relied upon.

We will therefore assume PHP is available in the path and is named "php" for execute ourselves. That is, the #!/usr/bin/env php is working and valid, unless a PHP constant is defined, which can be done by the shell wrapper.

The DRUSH_COMMAND constant is initialised to the value of this function when environment.inc is loaded.

See also

DRUSH_COMMAND

1 call to drush_find_drush()
_drush_bootstrap_drush in includes/environment.inc
Initial Drush bootstrap phase.

File

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

Code

function drush_find_drush() {
  $php = drush_get_option('php');
  if (isset($php)) {
    $drush = $php . " " . realpath($_SERVER['argv'][0]) . " --php=$php";
  }
  else {
    $drush = realpath($_SERVER['argv']['0']);
  }
  return $drush;
}