function drush_is_local_host

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

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


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

Return value

True if the host is local.

6 calls to drush_is_local_host()
drush_sitealias_evaluate_path in includes/
Evaluate a path from its shorthand form to a literal path usable by rsync.
drush_sitealias_get_db_spec in includes/
Return the $db_spec record for the database associated with the provided alias record. which will be used to first add the database information to the alias records, invoking sql-conf to look them up if necessary.
drush_sitealias_set_alias_context in includes/
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 in includes/
Generate a command to execute.
_drush_sitealias_preflight_path in includes/
Call prior to drush_sitealias_evaluate_path to insure that any site-specific aliases associated with any local site in $path are defined.

... See full list


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


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

  // We'll start out by asking for uname -n via php_uname, since
  // that is most portable.  On Linux, uname -n returns the contents of
  // /etc/hostname, which, according to `man hostname`, should never
  // contain the fqdn.  We will therefore also try `hostname -f`, and
  // see if we can get the fqdn from that.
  $uname = php_uname('n');
  if ((strpos($uname, '.') === FALSE) && (!drush_is_windows())) {
    $hostname = exec('hostname -f');
    if (!empty($hostname)) {
      $uname = $hostname;
  // We will require an exact match if we have the fqdn for this
  // host; if we only have the short name, then we will consider it
  // to be a match if it matches the first part of the remote-host
  // item (up to the first dot).
  return (strpos($uname, '.') !== FALSE) ? ($host == $uname) : substr($host . '.', , strlen($uname) + ) == $uname . '.';