function drush_complete_process_argv

8.0.x drush_complete_process_argv()
6.x drush_complete_process_argv()
7.x drush_complete_process_argv()
5.x drush_complete_process_argv()
master drush_complete_process_argv()

This function resets the raw arguments so that Drush can parse the command as if it was run directly. The shell complete command passes the full command line as an argument, and the --early and --complete-debug options have to come before that, and the "drush" bash script will add a --php option on the end, so we end up with something like this:

/path/to/drush.php --early=includes/ [--complete-debug] drush [@alias] [command]... --php=/usr/bin/php

Note that "drush" occurs twice, and also that the second occurrence could be an alias, so we can't easily use it as to detect the start of the actual command. Hence our approach is to remove the initial "drush" and then any options directly following that - what remains is then the command we need to complete - i.e.:

drush [@alias] [command]...

Note that if completion is initiated following a space an empty argument is added to argv. So in that case argv looks something like this: array ( '0' => '/path/to/drush.php', '1' => '--early=includes/', '2' => 'drush', '3' => 'topic', '4' => '', '5' => '--php=/usr/bin/php', );

Return value

$args Array of arguments (argv), excluding the initial command and options associated with the complete call. array ( '0' => 'drush', '1' => 'topic', '2' => '', );

1 call to drush_complete_process_argv()
drush_early_complete in includes/
Produce autocomplete output.


includes/, line 228
Provide completion output for shells.


function drush_complete_process_argv() {
  $argv = drush_get_context('argv');
  // Remove the first argument, which will be the "drush" command.
  while (substr($arg = array_shift($argv), 0, 2) == '--') {
    // We remove all options, until we get to a non option, which
    // marks the start of the actual command we are trying to complete.
  // Replace the initial argument.
  array_unshift($argv, $arg);
  // Remove the --php option at the end if exists (added by the "drush" shell
  // script that is called when completion is requested).
  if (substr(end($argv), 0, 6) == '--php=') {
  drush_set_context('argv', $argv);
  // Reparse arguments, site alias, and command.
  // Ensure the base environment is configures, so tests look in the correct
  // places.
  // Check for and record any site alias.

  // Return the new argv for easy reference.
  return $argv;