function find_wrapper_or_launcher

8.0.x startup.inc find_wrapper_or_launcher($location)
master startup.inc find_wrapper_or_launcher($location)

Checks the provided location and return the appropriate Drush wrapper or Drush launcher script, if found.

3 calls to find_wrapper_or_launcher()
drush_backend_invoke_concurrent in includes/backend.inc
Execute a new local or remote command in a new process.
drush_preflight_command_dispatch in includes/preflight.inc
Handle any command preprocessing that may need to be done, including potentially redispatching the command immediately (e.g. for remote commands).
drush_startup in includes/startup.inc
drush_startup is called once, by the Drush "finder" script -- the "drush" script at the Drush root. It finds the correct Drush "wrapper" or "launcher" script to use, and executes it with process replacement.

File

includes/startup.inc, line 51
Functions used when Drush is starting up.

Code

function find_wrapper_or_launcher($location) {
  // We look for a "Drush wrapper" script that might
  // be stored in the root of a site.  If there is
  // no wrapper script, then we look for the
  // drush.launcher script in vendor/bin.  We try just a
  // few of the most common locations; if the user relocates
  // their vendor directory anywhere else, then they must
  // use a wrapper script to locate it.  See the comment in
  // 'examples/drush' for details.
  //
  // We are somewhat "loose" about whether we are looking
  // for "drush" or "drush.launcher", because in old versions
  // of Drush, the "drush launcher" was named "drush".
  // Otherwise, there wouldn't be any point in looking for
  // "drush.launcher" at the root, or "drush" in a vendor directory.
  // We also allow users to rename their drush wrapper to
  // 'drush.wrapper' to avoid conflicting with a directory named
  // 'drush' at the site root.
  $drush_locations = array(
    "drush",
    "vendor/bin/drush",
    "../vendor/bin/drush",
    "sites/all/vendor/bin/drush",
    "sites/all/vendor/drush/drush/drush",
    "sites/all/drush/drush/drush",
    "drush/drush/drush",
  );

  foreach ($drush_locations as $d) {
    foreach (array('.launcher', '.wrapper', '') as $suffix) {
      if (is_file("$location/$d$suffix")) {
        return "$location/$d$suffix";
      }
    }
  }
  return "";
}