Considering the fact that most modules define permissions with spaces in them, this is pretty useless without this working. Fortunately, the fix for it is pretty easy. I don't know the best way to create a patch so I am just putting the updated drush_permissions_api_perm_grant() function here and hoping someone can create the actual patch for it.

function drush_permissions_api_perm_grant() {
  $args = func_get_args();
  $role = $args[0];
  array_shift($args);
  // The $args array splits command line arguments on the spaces. Permissions may have spaces in them and are to be entered in a comma separated list.
  $perms = explode(',', implode(' ', $args));
  $module = drush_get_option('module');

  if ($module) {
    permissions_grant_all_permissions_by_module($role, $module);
    drush_print(dt('Granted all !module permissions to !role.', array('!module' => $module, '!role' => $role)));
  }
  elseif ($perms[0] == 'all') {
    permissions_grant_all_permissions($role);
    drush_print(dt('All permissions granted to !role.', array('!role' => $role)));
  }
  else {
    permissions_grant_permissions($role, $perms);
    drush_print(dt('Specified Permissions granted to !role.', array('!role' => $role)));
  }
}

I think that the perm-revoke command probably needs a similar fix. I tested the above and it worked for me.

Comments

ebeyrent’s picture

Assigned: Unassigned » ebeyrent

Thanks, and good find. I'll take a look at this as soon as I can.

Ken Wolf’s picture

Single quotes can be used, in the cmd line invocation of this drush command, to get the existing code to handle permissions with spaces.
-Ken Wolf

doublejosh’s picture

This doesn't work for me.

INPUT: drush perm-grant 'anonymous user' access_devel_information --uri=mysite.local

ERROR: The drush command 'perm-grant anonymous user access_devel_information' could not be found.

doublejosh’s picture

...and my fault.

1) Didn't realize I had to enable the module, thought I could just make use of the API functions.
http://drupal.org/node/897774

2) Thought I needed to change spaced to underscores in permissions, nope.
COMMAND: drush perm-grant 'anonymous user' 'access devel information' --uri=mysite.local

Thanks for the this awesome module!
My environment workflow just got more smooth.

ebeyrent’s picture

Status: Active » Closed (works as designed)