function drush_sandwich_make_me_a_sandwich_validate

8.0.x sandwich.drush.inc drush_sandwich_make_me_a_sandwich_validate()
6.x sandwich.drush.inc drush_sandwich_make_me_a_sandwich_validate()
7.x sandwich.drush.inc drush_sandwich_make_me_a_sandwich_validate()
3.x sandwich.drush.inc drush_sandwich_make_me_a_sandwich_validate()
4.x sandwich.drush.inc drush_sandwich_make_me_a_sandwich_validate()
5.x sandwich.drush.inc drush_sandwich_make_me_a_sandwich_validate()
master sandwich.drush.inc drush_sandwich_make_me_a_sandwich_validate()

Implements drush_hook_COMMAND_validate().

The validate command should exit with `return drush_set_error(...)` to stop execution of the command. In practice, calling drush_set_error OR returning FALSE is sufficient. See drush.api.php for more details.

File

examples/sandwich.drush.inc, line 174
Example drush command.

Code

function drush_sandwich_make_me_a_sandwich_validate() {
  if (drush_is_windows()) {
    // $name = drush_get_username();
    // @todo Implement check for elevated process using w32api
    // as sudo is not available for Windows
    // @see http://php.net/manual/en/book.w32api.php
    // @see http://social.msdn.microsoft.com/Forums/en/clr/thread/0957c58c-b30b-4972-a319-015df11b427d
  }
  else {
    $name = posix_getpwuid(posix_geteuid());
    if ($name['name'] !== 'root') {
      return drush_set_error('MAKE_IT_YOUSELF', dt('What? Make your own sandwich.'));
    }
  }
}