function drush_set_config_special_contexts

8.0.x drush_set_config_special_contexts(&$options)
6.x drush_set_config_special_contexts(&$options)
7.x drush_set_config_special_contexts(&$options)
3.x drush_set_config_special_contexts(&$options)
4.x drush_set_config_special_contexts(&$options)
5.x drush_set_config_special_contexts(&$options)
master drush_set_config_special_contexts(&$options)

There are certain options such as 'site-aliases' and 'command-specific' that must be merged together if defined in multiple drush configuration files. If we did not do this merge, then the last configuration file that defined any of these properties would overwrite all of the options that came before in previously-loaded configuration files. We place all of them into their own context so that this does not happen.

6 calls to drush_set_config_special_contexts()
drush_parse_args in includes/
Parse console arguments.
drush_set_config_options in includes/
drush_sitealias_get_record in includes/
Get a site alias record given an alias name or site specification.
drush_sitealias_load_all in includes/
Load every alias file that can be found anywhere in the alias search path.
_drush_sitealias_find_and_load_alias in includes/
Traverses the alias search path and finds the specified alias record.

... See full list


includes/, line 219
The Drush context API implementation.


function drush_set_config_special_contexts(&$options) {
  if (isset($options) && is_array($options)) {
    $has_command_specific = array_key_exists('command-specific', $options);
    // Change the keys of the site aliases from 'alias' to '@alias'
    if (array_key_exists('site-aliases', $options)) {
      $user_aliases = $options['site-aliases'];
      $options['site-aliases'] = array();
      foreach ($user_aliases as $alias_name => $alias_value) {
        if (substr($alias_name, 0, 1) != '@') {
          $alias_name = "@$alias_name";
        $options['site-aliases'][$alias_name] = $alias_value;
    // Expand -s into --simulate, etc.

    foreach (drush_get_global_options() as $name => $info) {
      if (is_array($info)) {
        // For any global option with the 'merge-pathlist' or 'merge-associative' flag, set its
        // value in the specified context.  The option is 'merged' because we
        // load $options with the value from the context prior to including the
        // configuration file.  If the configuration file sets $option['special'][] = 'value',
        // then the configuration will be merged.  $option['special'] = array(...), on the
        // other hand, will replace rather than merge the values together.
        if ((array_key_exists($name, $options)) && (array_key_exists('merge', $info) || (array_key_exists('merge-pathlist', $info) || array_key_exists('merge-associative', $info)))) {
          $context = array_key_exists('context', $info) ? $info['context'] : $name;
          $cache = &drush_get_context($context);
          $value = $options[$name];
          if (!is_array($value) && array_key_exists('merge-pathlist', $info)) {
            $value = explode(PATH_SEPARATOR, $value);
          if (array_key_exists('merge-associative', $info)) {
            foreach ($value as $subkey => $subvalue) {
              $cache[$subkey] = array_merge(isset($cache[$subkey]) ? $cache[$subkey] : array(), $subvalue);
          else {
            $cache = array_unique(array_merge($cache, $value));
          // Once we have moved the option to its special context, we
          // can remove it from its option context -- unless 'propagate-cli-value'
          // is set, in which case we need to let it stick around in options
          // in case it is needed in backend invoke.
          if (!array_key_exists('propagate-cli-value', $info)) {

    // If command-specific options were set and if we already have
    // a command, then apply the command-specific options immediately.
    if ($has_command_specific) {