function drush_correct_absolute_path_for_exec

8.0.x filesystem.inc drush_correct_absolute_path_for_exec($path, $os = NULL)
6.x filesystem.inc drush_correct_absolute_path_for_exec($path, $os = NULL)
7.x filesystem.inc drush_correct_absolute_path_for_exec($path, $os = NULL)
5.x filesystem.inc drush_correct_absolute_path_for_exec($path, $os = NULL)
master filesystem.inc drush_correct_absolute_path_for_exec($path, $os = NULL)

If we are going to pass a path to exec or proc_open, then we need to fix it up under CYGWIN or MINGW. In both of these environments, PHP works with absolute paths such as "C:\path". CYGWIN expects these to be converted to "/cygdrive/c/path" and MINGW expects these to be converted to "/c/path"; otherwise, the exec will not work.

This call does nothing if the parameter is not an absolute path, or we are not running under CYGWIN / MINGW.

UPDATE: It seems I was mistaken; this is only necessary if we are using cwRsync. We do not need to correct every path to exec or proc_open (thank god).

Related topics

1 call to drush_correct_absolute_path_for_exec()
drush_sitealias_evaluate_path in includes/sitealias.inc
Evaluate a path from its shorthand form to a literal path usable by rsync.

File

includes/filesystem.inc, line 55
Filesystem utilities.

Code

function drush_correct_absolute_path_for_exec($path, $os = NULL) {
  if (drush_is_windows() && drush_is_absolute_path($path, "WINNT")) {
    if (drush_is_mingw($os)) {
      $path = preg_replace('/(\w):/', '/${1}', str_replace('\\', '/', $path));
    }
    elseif (drush_is_cygwin($os)) {
      $path = preg_replace('/(\w):/', '/cygdrive/${1}', str_replace('\\', '/', $path));
    }
  }
  return $path;
}