function drush_sitealias_set_alias_context

8.0.x drush_sitealias_set_alias_context($site_alias_settings, $prefix = '')
6.x drush_sitealias_set_alias_context($site_alias_settings, $prefix = '')
7.x drush_sitealias_set_alias_context($site_alias_settings, $prefix = '')
3.x drush_sitealias_set_alias_context($site_alias_settings, $prefix = '')
4.x drush_sitealias_set_alias_context($site_alias_settings, $prefix = '')
5.x drush_sitealias_set_alias_context($site_alias_settings, $prefix = '')
master drush_sitealias_set_alias_context($site_alias_settings, $prefix = '')

Given a site alias record, copy selected fields from it into the drush 'alias' context. The 'alias' context has lower precedence than the 'options' context, so values set by an alias record can be overridden by command-line parameters.


site_alias_settings: An alias record

prefix: The prefix value to afix to the beginning of every key set. For example, if this function is called once with 'source-' and again with 'destination-' prefixes, then the source database records will be stored in 'source-databases', and the destination database records will be in 'destination-databases'.

3 calls to drush_sitealias_set_alias_context()
drush_sitealias_evaluate_path in includes/
Evaluate a path from its shorthand form to a literal path usable by rsync.
_drush_sitealias_set_context_by_name in includes/
Looks up the specified alias record and calls through to drush_sitealias_set_alias_context, below.
_drush_sql_sync in commands/sql/


includes/, line 1256
The site alias API.


function drush_sitealias_set_alias_context($site_alias_settings, $prefix = '') {
  $options = drush_get_context('alias');

  // There are some items that we should just skip
  $skip_list = array('site-aliases', 'command-specific');
  // Also skip 'remote-host' and 'remote-user' if 'remote-host' is actually
  // the local machine
  if (array_key_exists('remote-host', $site_alias_settings) && drush_is_local_host($site_alias_settings['remote-host'])) {
    $skip_list[] = 'remote-host';
    $skip_list[] = 'remote-user';
  // Transfer all options from the site alias to the drush options
  // in the 'alias' context.
  foreach ($site_alias_settings as $key => $value) {
    // Special handling for path aliases:
    if ($key == "path-aliases") {
      foreach (array('%drush-script', '%dump', '%include') as $path_key) {
        if (array_key_exists($path_key, $value)) {
          $options[$prefix . substr($path_key, 1)] = $value[$path_key];
    elseif (!in_array($key, $skip_list)) {
      $options[$prefix . $key] = $value;
  drush_set_config_options('alias', $options);