function drush_is_local_host

8.0.x environment.inc drush_is_local_host($host)
6.x environment.inc drush_is_local_host($host)
7.x environment.inc drush_is_local_host($host)
3.x environment.inc drush_is_local_host($host)
4.x environment.inc drush_is_local_host($host)
5.x environment.inc drush_is_local_host($host)
master environment.inc drush_is_local_host($host)

Make a determination whether or not the given host is local or not.

Parameters

host: A hostname, 'localhost' or '127.0.0.1'.

Return value

True if the host is local.

5 calls to drush_is_local_host()
drush_sitealias_evaluate_path in includes/sitealias.inc
Evaluate a path from its shorthand form to a literal path usable by rsync.
drush_sitealias_set_alias_context in includes/sitealias.inc
Given a site alias record, copy selected fields from it into the drush 'alias' context. The 'alias' context has lower precedence than the 'cli' context, so values set by an alias record can be overridden by…
_drush_backend_generate_command_sitealias in includes/backend.inc
Generate a command to execute.
_drush_sitealias_preflight_path in includes/sitealias.inc
Call prior to drush_sitealias_evaluate_path to insure that any site-specific aliases associated with any local site in $path are defined.
_drush_sql_get_spec_from_options in commands/sql/sql.drush.inc

File

includes/environment.inc, line 1344
Functions used by drush to query the environment and setting the current configuration.

Code

function drush_is_local_host($host) {
  // In order for this to work right, you must use 'localhost' or '127.0.0.1'
  // or the machine returned by 'uname -n' for your 'remote-host' entry in
  // your site alias.
  if (($host == 'localhost') || ($host == '127.0.0.1')) {
    return TRUE;
  }

  // If uname -n returns an fqdn (that is, uname -n == hostname -f),
  // then we will require that it exactly match the host in order
  // to be considered local.  However, the usual convention is for
  // uname -n to return only the node name (that is, uname -n == hostname -a).
  // When this is the case, we will consider $host to be local if the
  // machine portion of it (everything up to the first dot) matches the
  // current value of uname -n.  We prefer uname -n to hostname as
  // the output of uname is more regular than hostname.
  $uname = php_uname('n');
  return (strpos($uname, '.') !== FALSE) ? ($host == $uname) : substr($host . '.', 0, strlen($uname) + 1) == $uname . '.';
}