function _drush_bootstrap_base_environment

6.x bootstrap.inc _drush_bootstrap_base_environment()
5.x bootstrap.inc _drush_bootstrap_base_environment()

Sets up basic environment that controls where Drush looks for files on a system-wide basis. Important to call for "early" functions that need to work with unit tests.

2 calls to _drush_bootstrap_base_environment()
drush_complete_process_argv in includes/complete.inc
This function resets the raw arguments so that Drush can parse the command as if it was run directly. The shell complete command passes the full command line as an argument, and the --early and --complete-debug options have to come before that, and…
_drush_bootstrap_drush in includes/bootstrap.inc
Initial Drush bootstrap phase.

File

includes/bootstrap.inc, line 598
Drush bootstrapping code.

Code

function _drush_bootstrap_base_environment() {
  // Copy ETC_PREFIX and SHARE_PREFIX from environment variables if available.
  // This alters where we check for server-wide config and alias files.
  // Used by unit test suite to provide a clean environment.
  if (getenv('ETC_PREFIX')) {
    drush_set_context('ETC_PREFIX', getenv('ETC_PREFIX'));
  }
  if (getenv('SHARE_PREFIX')) {
    drush_set_context('SHARE_PREFIX', getenv('SHARE_PREFIX'));
  }

  drush_set_context('DOC_PREFIX', DRUSH_BASE_PATH);
  if (!file_exists(DRUSH_BASE_PATH . '/README.md') && file_exists(drush_get_context('SHARE_PREFIX', '/usr') . '/share/doc/drush' . '/README.md')) {
    drush_set_context('DOC_PREFIX', drush_get_context('SHARE_PREFIX', '/usr') . '/share/doc/drush');
  }
  $alias_path = &drush_get_context('ALIAS_PATH');
  $default_prefix_configuration = drush_is_windows() ? getenv('ALLUSERSPROFILE') . '/Drush' : '';
  $default_prefix_commandfile = drush_is_windows() ? getenv('ALLUSERSPROFILE') . '/Drush' : '/usr';
  $site_wide_configuration_dir = drush_get_context('ETC_PREFIX', $default_prefix_configuration) . '/etc/drush';
  $site_wide_commandfile_dir = drush_get_context('SHARE_PREFIX', $default_prefix_commandfile) . '/share/drush/commands';
  $alias_path[] = $site_wide_configuration_dir;
  drush_set_context('DRUSH_SITE_WIDE_CONFIGURATION', $site_wide_configuration_dir);
  drush_set_context('DRUSH_SITE_WIDE_COMMANDFILES', $site_wide_commandfile_dir);
  $alias_path[] = dirname(__FILE__) . '/..';
  if (!is_null(drush_server_home())) {
    $alias_path[] = drush_server_home() . '/.drush';
    drush_set_context('DRUSH_PER_USER_CONFIGURATION', drush_server_home() . '/.drush');
  }
}