function drush_sitealias_get_envar_filename

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

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

Parameters

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.

4 calls to drush_sitealias_get_envar_filename()
drush_sitealias_site_clear in includes/sitealias.inc
Un-set the currently use'd site alias.
drush_sitealias_site_get in includes/sitealias.inc
Read the tmp file where the persistent site setting is stored.
drush_sitealias_site_set in commands/core/sitealias.drush.inc
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

File

includes/sitealias.inc, line 2183
The site alias API.

Code

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;
}