Closed (fixed)
Project:
Drush
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
25 Mar 2009 at 19:32 UTC
Updated:
26 Mar 2009 at 20:21 UTC
I've been trying to get the drush command to return an exit value by returning that value in my command callback, but whatever I seem to return (or nothing) drush seems to return an exit code of 1 to my launch script. I tested that same launch script with a trivial .php file which does nothing but call exit(0) or exit(1) and got the expected results. I notice that there is a TODO at the end of drush_bootstrap which seems to indicate that proper exit code setting is not yet working.
Can you clarify whether this should be working now or not and what I'd have to code in my command to return a 0 or nonzero return code from the drush command line?
Comments
Comment #1
adrian commentedAt the moment, drush considers 0 as not being able to complete the command (ie: some drupal code pulled in an exit of it's own)
If drush completed successfully , it returns 1.
if there was a drush error, it returns 2. When using the --backend flag, you will get an error log from the returned json that can be used to determine what went wrong with the script.
if drush_set_error('SOME_ERROR_HERE', 'error message'); is called at any point of the script, the return code will be 2.
If it manages to complete everything it needed to do, without any errors, it will return 1.
The way it is now, it will never return 0.
This is kind of difficult, because we need to be able to determine whether it was actually successful, and didn't just randomly exit() at some point in the drupal code (such as when you accidentally call anything that uses a drupal_goto(), which does an exit();)
Comment #2
sprior commentedOK, sounds like I'll settle for outputting some message that I can test for success or failure.
Thanks
Steve