function drush_cwd

8.0.x drush_cwd()
6.x drush_cwd()
7.x drush_cwd()
3.x drush_cwd()
4.x drush_cwd()
5.x drush_cwd()
master drush_cwd()

Returns the current working directory.

This is the directory as it was when drush was started, not the directory we are currently in. For that, use getcwd() directly.

7 calls to drush_cwd()
drush_core_php_script in commands/core/
Command callback. Runs "naked" php scripts and drush "shebang" scripts ("#!/usr/bin/env drush").
drush_find_tmp in includes/
Returns the path to a temporary directory.
drush_locate_root in includes/
Exhaustive depth-first search to try and locate the Drupal root directory. This makes it possible to run Drush from a subdirectory of the drupal root.
drush_preflight in includes/
During the initialization of Drush, this is the first step where we load our configuration and commandfiles, and select the site we are going to operate on; however, we take no irreversible actions (e.g. site bootstrapping). This allows commands that…
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.

... See full list


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


function drush_cwd() {
  if ($path = drush_get_context('DRUSH_OLDCWD')) {
    return $path;
  // We use PWD if available because getcwd() resolves symlinks, which
  // could take us outside of the Drupal root, making it impossible to find.
  // $_SERVER['PWD'] isn't set on windows and generates a Notice.
  $path = isset($_SERVER['PWD']) ? $_SERVER['PWD'] : '';
  if (empty($path)) {
    $path = getcwd();

  // Convert windows paths.
  $path = _drush_convert_path($path);

  // Save original working dir case some command wants it.
  drush_set_context('DRUSH_OLDCWD', $path);

  return $path;