Closed (works as designed)
Project:
Drush
Component:
Code
Priority:
Minor
Category:
Bug report
Assigned:
Reporter:
Created:
13 Dec 2009 at 04:59 UTC
Updated:
19 Jan 2010 at 04:36 UTC
I noticed that drush_backend_invoke() assumes that the first word in $args is a command and the rest of the words are arguments. This is not true for many commands like 'sql query'. This is typically not a problem - the command gets invoked fine. Thus I set this to minor.
Note that the autocomplete folks really begged us to use one word commands like 'sql:query' or 'sql-query' instead of 'sql query'. So the right answer here might be to change many command names to always be prefixed. This might be more tolerable now that we have command aliases.
Comments
Comment #1
adrian commenteddrush_backend_invoke assumes
1) $command is a string
2) $args is an array, with OPTIONS as string indexed items and ARGUMENTS as numerically indexed items.
so in the command
you would have
hence :
Comment #2
adrian commentedalso, see drush_backend_invoke_args()
Comment #3
greg.1.anderson commentedThere is this function:
The
$command = array_shift($args);assumes that the first word is the command, and the second and subsequent words are args._drush_backend_generate_commandputs everything back together correctly again, so it's not a huge problem, but please also see the discussion in #658420: helper functions for drush_backend_invoke().Perhaps the best solution would be to have
drush_backend_invoke_args($command, $args, ...)call through todrush_backend_invoke_args($args, ...)after first exploding $command and merging it with $args. In this case, then_drush_backend_generate_commandalso would take only $args.If you were calling backend invoke from code, you'd do it as you suggest in #1, but if you were re-dispatching using the $args list that were passed in on the command line you could instead do something like this:
(n.b. the two polymorphic drush_backend_invoke_args probably need different names due to the default arguments; I apologize for any confusion caused by giving them the same name here.)
In this case, it is neither assumed nor specified how many elements of $args are the command and how many are the other arguments.
Comment #4
moshe weitzman commentedcommand must now be single word. spaces in commands are deprecated. nothing to do here. if i am wrong, please reopen.