function drush_find_drush

8.0.x drush_find_drush()
6.x drush_find_drush()
7.x drush_find_drush()
3.x drush_find_drush()
4.x drush_find_drush()
5.x drush_find_drush()
master 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 is loaded.

See also


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


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


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;