function drush_preflight_tilde_expansion

8.0.x drush_preflight_tilde_expansion(&$command)
master drush_preflight_tilde_expansion(&$command)

Look for instances of arguments or parameters that start with "~/". Replace these with "$HOME/".

Note that this function is called _after_ Drush does its redispatch checks; tildes are passed through unmodified on a redispatch, and are only expanded when a command is handled locally.

1 call to drush_preflight_tilde_expansion()
drush_dispatch in includes/
Given a command record, dispatch it as if it were the original command. Executes in the currently bootstrapped site using the current option contexts. Note that drush_dispatch will not bootstrap any further than the current command has already…


includes/, line 675
Preflight, postflight and shutdown code.


function drush_preflight_tilde_expansion(&$command) {
  // Skip tilde expansion for commands that use
  // stict option handling, or those that explicitly
  // turn it off via $command['tilde-expansion'] = FALSE.
  if ($command['tilde-expansion'] && !$command['strict-option-handling']) {
    $cli = &drush_get_context('cli');
    $match = '#^~/#';
    $replacement = drush_server_home() . '/';
    foreach ($cli as $key => $value) {
      if (is_string($value) && preg_match($match, $value)) {
        $cli[$key] = preg_replace($match, $replacement, $value);
    $command['arguments'] = array_map(function($value) use ($match, $replacement) {
      return is_string($value) ? preg_replace($match, $replacement, $value) : $value;
    }, $command['arguments']);