function drush_escapeshellarg

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

Platform-dependent version of escapeshellarg(). Given the target platform, return an appropriately-escaped string. The target platform may be omitted for args that are /known/ to be for the local machine.

Related topics

19 calls to drush_escapeshellarg()
drush_build_drush_command in includes/environment.inc
Build a drush command suitable for use for drush to call itself e.g. in backend_invoke.
drush_core_execute in commands/core/core.drush.inc
Command callback. Execute specified shell code. Often used by shell aliases that start with !.
drush_remote_host in includes/exec.inc
Determine the remote host (username@hostname.tld) for the specified site.
drush_shell_proc_build in includes/exec.inc
Build an SSH string including an optional fragment of bash. Commands that use this should also merge drush_shell_proc_build_options() into their command options.
drush_sitealias_evaluate_path in includes/sitealias.inc
Evaluate a path from its shorthand form to a literal path usable by rsync.

... See full list

File

includes/exec.inc, line 318

Code

function drush_escapeshellarg($arg, $os = NULL) {
  // Short-circuit escaping for simple params (keep stuff readable)
  if (preg_match('|^[a-zA-Z0-9.:/_-]*$|', $arg)) {
    return $arg;
  }
  elseif (drush_is_windows($os)) {
    return _drush_escapeshellarg_windows($arg);
  }
  else {
    return _drush_escapeshellarg_linux($arg);
  }
}