function drush_escapeshellarg

8.0.x drush_escapeshellarg($arg, $os = NULL, $raw = FALSE)
6.x drush_escapeshellarg($arg, $os = NULL)
7.x drush_escapeshellarg($arg, $os = NULL, $raw = FALSE)
4.x drush_escapeshellarg($arg)
5.x drush_escapeshellarg($arg, $os = NULL)
master 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/
Build a drush command suitable for use for Drush to call itself e.g. in backend_invoke.
drush_core_execute in commands/core/
Command callback. Execute specified shell code. Often used by shell aliases that start with !.
drush_remote_host in includes/
Determine the remote host (username@hostname.tld) for the specified site.
drush_set_environment_vars in includes/
Set Env. Variables for given site-alias.
drush_shell_proc_build in includes/
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


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


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);