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.

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 581
Functions used by drush to query the environment and setting the current configuration.


function drush_find_drush() {
  $drush = realpath($_SERVER['argv']['0']);
  // TODO: On Windows, if we leave $drush as-is, then callbacks will
  // be done just as we were called by the batch file:  php.exe C:\path\drush.php
  // We could also convert drush.php to drush.bat to run the batch file again,
  // but this works just as well.
  return $drush;