function drush_wrap_with_quotes

8.0.x exec.inc drush_wrap_with_quotes($arg)
6.x exec.inc drush_wrap_with_quotes($arg)
7.x exec.inc drush_wrap_with_quotes($arg)
5.x exec.inc drush_wrap_with_quotes($arg)
master exec.inc drush_wrap_with_quotes($arg)

Make an attempt to simply wrap the arg with the kind of quote characters it does not already contain. If it contains both kinds, then this function reverts to drush_escapeshellarg.

Related topics

1 call to drush_wrap_with_quotes()
drush_outputformat_list::format in commands/core/outputformat/list.inc

File

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

Code

function drush_wrap_with_quotes($arg) {
  $has_double = strpos($arg, '"') !== FALSE;
  $has_single = strpos($arg, "'") !== FALSE;
  if ($has_double && $has_single) {
    return drush_escapeshellarg($arg);
  }
  elseif ($has_double) {
    return "'" . $arg . "'";
  }
  else {
    return '"' . $arg . '"';
  }
}