function drush_sitealias_get_envar_filename

8.0.x drush_sitealias_get_envar_filename($filename_prefix = 'drush-drupal-site-')
6.x drush_sitealias_get_envar_filename($filename_prefix = 'drush-drupal-site-')
7.x drush_sitealias_get_envar_filename($filename_prefix = 'drush-drupal-site-')
5.x drush_sitealias_get_envar_filename($filename_prefix = 'drush-drupal-site-')
master drush_sitealias_get_envar_filename($filename_prefix = 'drush-drupal-site-')

Returns the filename for the file that stores the DRUPAL_SITE variable.


string $filename_prefix: An arbitrary string to prefix the filename with.

Return value

string|false Returns the full path to temp file if possible, or FALSE if not.

3 calls to drush_sitealias_get_envar_filename()
drush_sitealias_site_get in includes/
Read the tmp file where the persistent site setting is stored.
drush_sitealias_site_set in commands/core/
Set the DRUPAL_SITE variable by writing it out to a temporary file that we then source for persistent site switching.
siteSetUnitTest::testSiteSet in tests/siteSetUnitTest.php


includes/, line 2161
The site alias API.


function drush_sitealias_get_envar_filename($filename_prefix = 'drush-drupal-site-') {
  $shell_pid = getenv('DRUSH_SHELL_PID');
  if (!$shell_pid && function_exists('posix_getppid')) {
    $shell_pid = posix_getppid();
  if (!$shell_pid) {
    return FALSE;

  $tmp = getenv('TMPDIR') ? getenv('TMPDIR') : '/tmp';
  $username = drush_get_username();

  return "{$tmp}/drush-env-{$username}/{$filename_prefix}" . $shell_pid;