function drush_sitealias_check_arg_and_site_set

8.0.x drush_sitealias_check_arg_and_site_set()
7.x drush_sitealias_check_arg_and_site_set()
master drush_sitealias_check_arg_and_site_set()

Check to see if the user specified an alias in an arguement, or via site-set. If so, return the name of the alias.

If the alias came from args, then remove it from args.

1 call to drush_sitealias_check_arg_and_site_set()
drush_preflight in includes/
During the initialization of Drush, this is the first step where we load our configuration and commandfiles, and select the site we are going to operate on; however, we take no irreversible actions (e.g. site bootstrapping). This allows commands that…


includes/, line 23
The site alias API.


function drush_sitealias_check_arg_and_site_set() {
  $args = drush_get_arguments();
  $target_alias = FALSE;

  // Test to see if the first arg is a valid alias identifier.
  // If the first arguement is a well-formed identifier, but we
  // cannot find a record for it, then we will fail with an error.
  if (!empty($args) && drush_sitealias_valid_alias_format($args[0])) {
    // Pop the alias off the arguments list first thing.
    $target_alias = array_shift($args);
  else {
    // If the user did not specify an alias via an argument,
    // check to see if a site env was set.
    $target_alias = drush_sitealias_site_get();

  // Record the user's desired target alias name
  if ($target_alias) {
    drush_set_context('DRUSH_TARGET_SITE_ALIAS', $target_alias);
  return $target_alias;