function drush_select_engine

8.0.x drush_select_engine($config, $engine_info, $preferred = NULL)
7.x drush_select_engine($config, $engine_info, $preferred = NULL)
master drush_select_engine($config, $engine_info, $preferred = NULL)

Selects an engine between the available ones.


  • preferred engine, if available.
  • user supplied engine via cli.
  • default engine from engine type / command declaration.
  • the first engine available.


array $config: Engine type configuration. My be overridden in command declaration.

array $engine_info: Engine type declaration.

string $default: Preferred engine.

Return value

string Selected engine.

3 calls to drush_select_engine()
drush_load_command_engine in includes/
Selects and loads an engine implementing the given type.
drush_load_engine in includes/
Loads and validate an engine of the given type.
drush_merge_engine_data in includes/
Add command structure info from each engine type back into the command.


includes/, line 427
The drush engines API implementation and helpers.


function drush_select_engine($config, $engine_info, $preferred = NULL) {
  $engines = array_keys($engine_info['engines']);

  if (in_array($preferred, $engines)) {
    return $preferred;

  if (!empty($config['option'])) {
    $engine = drush_get_option($config['option'], FALSE);
    if ($engine && in_array($engine, $engines)) {
      return $engine;

  if (isset($config['default']) && in_array($config['default'], $engines)) {
    return $config['default'];

  return current($engines);