Download & Extend

Is there a way to know bootstrap is from Drush in my modules?

Project:Drush
Version:All-versions-4.x-dev
Component:Documentation
Category:task
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

Hey Drushies - I have some particular code that kills drush and I would like to throw a conditional in there to not to run that code when Drush is executing the bootstrap. Is there a global or something I can check to make sure it's not Drush running?

Comments

#1

Status:active» fixed

<?php
if (!function_exists('drush_verify_cli')) {
 
// do stuff.
}
?>

#2

Component:Miscellaneous» Documentation
Category:support request» task
Status:fixed» needs work

Okay, this is perhaps the most picky re-open ever. :)

I was thinking that whatever function we recommend here should be guaranteed to never change, regardless of drush version, and furthermore, we should document the function as being the sanctioned function to check for in modules.

I think that drush_verify_cli is a pretty good choice, but I slightly prefer drush_main. Either way, it just needs a comment in drush.php to advertise the policy.

#3

Awesome! Thanks guys :).

#4

Status:needs work» needs review

Here is a comment that recommends using drush_main.

AttachmentSize
document-fn-exists-drush-main.patch 450 bytes

#5

Status:needs review» reviewed & tested by the community

That's fine with me. I just suggested drush_verify_cli because I saw features module was already using it, but drush_main is probably less likely to change.

#6

Status:reviewed & tested by the community» fixed

Committed

#7

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nobody click here