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. Use raw to get an unquoted version of the escaped arg. Notice that you can't add quotes later until you know the platform.

Related topics

18 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_set_environment_vars in includes/environment.inc
Set Env. Variables for given site-alias.
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.

... See full list

File

includes/exec.inc, line 325
Functions for executing system commands. (e.g. exec(), system(), ...).

Code

function drush_escapeshellarg($arg, $os = NULL, $raw = FALSE) {
  // 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, $raw);
  }
  else {
    return _drush_escapeshellarg_linux($arg, $raw);
  }
}