function drush_get_username

8.0.x environment.inc drush_get_username()
6.x environment.inc drush_get_username()
7.x environment.inc drush_get_username()
5.x environment.inc drush_get_username()
master environment.inc drush_get_username()

Return the name of the user running drush.

3 calls to drush_get_username()
drush_directory_cache in includes/environment.inc
The path to the global cache directory.
drush_sitealias_get_envar_filename in includes/sitealias.inc
Returns the filename for the file that stores the DRUPAL_SITE variable.
siteSetUnitTest::testSiteSet in tests/siteSetUnitTest.php

File

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

Code

function drush_get_username() {
  $name = NULL;
  if (!$name = getenv("username")) { // Windows
    if (!$name = getenv("USER")) {
      // If USER not defined, use posix
      if (function_exists('posix_getpwuid')) {
        $processUser = posix_getpwuid(posix_geteuid());
        $name = $processUser['name'];
      }
    }
  }
  return $name;
}