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.

Related topics

19 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_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.
drush_sitealias_evaluate_path in includes/
Evaluate a path from its shorthand form to a literal path usable by rsync.

... See full list


includes/, line 318


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