5 * This is the Drush "finder" script, which is one part of the
6 * Drush dispatching chain. This is the script that
7 * should appear in your global $PATH, or, if using Composer
8 * (as usually the case), will be found in your vendor/bin directory.
11 * - Never copy this script to your site root. Copy examples/drush instead.
13 * - Never copy this script to a directory other than its install directory.
14 * Symlink to it instead.
17 * OVERVIEW OF DRUSH FINDER / WRAPPER / LAUNCHER SCRIPTS
19 * When the user types "drush", up to three scripts might be
20 * involved in the initial launch:
22 * "drush finder" -> "drush wrapper" -> "drush launcher".
24 * Brief description of each:
26 * - Drush finder: Finds the right Drush script and calls it.
27 * - Drush wrapper: Contains user customizations to options.
28 * - Drush launcher: Excutes drush.php.
30 * A full explanation of each script follows.
35 * - The "drush" script on the user's global $PATH
36 * - It's goal is to find the correct site-local Drush to run.
38 * The Drush finder will locate the correct site-local Drush to use
41 * a) The --root option
42 * b) The site set via `drush site set` in the current terminal
45 * If no site-local Drush is found, then the global Drush will be
46 * used. The Drush finder assumes that the global Drush is the
47 * "Drush launcher" found in the same directory as the Drush finder itself.
49 * If a site-local Drush is found, then the Drush finder will call
50 * either the "Drush wrapper", if it exists, or the "Drush launcher" if
51 * there is no wrapper script.
56 * - The drush.wrapper script that the user optionally copies and edits.
57 * - Its goal is to allow the user to add options when --local is in use
59 * The Drush "wrapper" is found at examples/drush.wrapper, and may optionally
60 * be copied to __ROOT__ by the user. It may be named either
61 * "drush" or "drush.wrapper". It will call the "Drush launcher"
62 * for the same site that it is located in. It adds the --local flag; the
63 * user is encouraged to add other options to the "Drush wrapper", e.g. to set
64 * the location where aliases and global commandfiles can be found.
65 * The Drush "finder" script always calls the "Drush wrapper" if it exists;
66 * however, if the user does not want to customize the early options of
67 * the site-local Drush (site-alias locations, etc.), then the wrapper does not
73 * - The "drush.launcher" script in vendor/bin
74 * - The bash script formerly called "drush"
76 * The "Drush launcher" is the traditional script that identifies PHP and
77 * sets up to call drush.php. It is called by the "Drush wrapper", or
78 * directly by the "Drush launcher" if there is no "Drush wrapper" in use.
81 * LOCATIONS FOR THESE SCRIPTS
83 * "Drush finder" : __ROOT__/vendor/bin/drush (composer install)
84 * __DRUSH__/drush (source)
86 * "Drush wrapper" : __ROOT__/drush (copied by user)
87 * __DRUSH__/examples/drush.wrapper (source)
89 * "Drush launcher" : __ROOT__/vendor/bin/drush.launcher (composer install)
90 * __DRUSH__/drush.launcher (source)
93 * BACKEND CALL DISPATCHING
95 * Backend calls are typically set up to call the "drush" script in the $PATH,
96 * or perhaps some might call __ROOT__/vendor/bin/drush directly, by way
97 * of the "drush-script" element in a site alias. In either event, this is
98 * the "drush finder" script.
100 * The backend call will always set --root. The "Drush finder" script
101 * always favors the site-local Drush stored with the site indicated by the
102 * --root option, if it exists. If there is no site-local Drush, then the
103 * "Drush finder" will behave as usual (i.e., it will end up calling the
104 * "Drush launcher" located next to it).
106 * This should always get you the correct "Drush" for local and remote calls.
107 * Note that it is also okay for aliases to specify a path directly to
108 * drush.launcher, in instances where it is known that a recent version of
109 * Drush is installed on the remote end.
112 if (!function_exists("drush_startup")) {
113 include __DIR__ . '/includes/startup.inc';
115 drush_startup($argv);