function _drush_escapeshellarg_windows

8.0.x exec.inc _drush_escapeshellarg_windows($arg, $raw = FALSE)
6.x exec.inc _drush_escapeshellarg_windows($arg)
7.x exec.inc _drush_escapeshellarg_windows($arg, $raw = FALSE)
4.x drush.inc _drush_escapeshellarg_windows($arg)
5.x exec.inc _drush_escapeshellarg_windows($arg)
master startup.inc _drush_escapeshellarg_windows($arg, $raw = FALSE)

Windows version of escapeshellarg().

@deprecated escapeshellarg needs to be cross-platform, because drush does not always know in advance whether an escaped arg will be used locally or on a remote system. See http://drupal.org/node/766080

Related topics

1 call to _drush_escapeshellarg_windows()
drush_escapeshellarg in includes/drush.inc
Platform-independent version of escapeshellarg(). This only works for local commands. TODO: Make a unified drush_escapeshellarg that works on Linux and Windows.

File

includes/drush.inc, line 1412
The drush API implementation and helpers.

Code

function _drush_escapeshellarg_windows($arg) {
  // Double the backslashes before any double quotes. Escape the double quotes.
  // (\" => \\\") && (" => \") =
  // (\" => \\") +
  $arg = preg_replace('/\\\"/', '\\\\\\"', $arg);
  // + (" => \")
  $arg = preg_replace('/"/', '\\"', $arg);

  // The same with single quotes.
  // (\' => \\\') && (' => \') =
  // (\' => \\') +
  $arg = preg_replace('/\\\'/', '\\\\\\\'', $arg);
  // + (' => \')
  $arg = preg_replace('/\'/', '\\\'', $arg);

  // Replace "\t", "\n", "\r", "\0", "\x0B" with a whitespace.
  $arg = str_replace(array("\t", "\n", "\r", "\0", "\x0B"), ' ', $arg);

  // Add surrounding quotes.
  $arg = '"' . $arg . '"';

  return $arg;
}