Drupal Association members fund grants that make connections all over the world.
From Sacha Chua's weblog entry, Drupal shell: quickly evaluating PHP statements in a Drupal context.
just updating the status :)
way to go, sacha!
I added help for this command and committed this to all branches. But it doesn't really work as I would hope. For example, drush eval "print_r($GLOBALS)" does not print anything. I think it cannot deal with the dollar sign. Help wanted.
drush eval "print_r($GLOBALS)"
This is probably because bash interprets dollar-signs in double-quoted strings as bash variables. To get around this, you could use single quotes, like so:
drush eval 'print_r($GLOBALS);'
This command works as expected. Otherwise, you can add a backslash before your dollar signs in double-quoted strings for PHP variables. I know it can be annoying, but short of that, I can't think of anything else we can do.
And for the sake of convenience, I've also included a patch that auto-appends a semicolon the end of the command if one isn't there. (I don't know about the rest of you, but it really annoys me to see PHP Parse error: syntax error, unexpected $end in ... every time I'm trying to do a simple one-liner just because I forgot the terminating semicolon.)
PHP Parse error: syntax error, unexpected $end in ...
Patch won't apply
ok, I recreated my patch. looks like drush_tools_eval() is now part of the module, so I just added a patch based on the latest 6.x-dev release.
Now you won't get that annoying nag error if you accidentally leave off a terminating semicolon.
perhaps we should conditionally add the semicolon so we don't ever get two? or maybe two does not matter.
in HEAD, we have now split this command to the drush_extras project. Perhaps it should move to drush project as it will always be version agnostic.
it doesn't matter if there are two semicolons. I've tested both cases and it still gets interpreted the same way—it just ignores the second one if it ends with two.
this exists in HEAD
Moya:drush adrian$ php /Users/adrian/Projects/hosting/drush/drush.php --root='/Users/adrian/Projects/hosting/platforms/DRUPAL-6' --uri='http://includetest.dev' help eval Run arbitrary PHP code in the context of Drupal
drush eval \"variable_set('hello', 'world');\" Sets the hello variable using Drupal API.
code PHP code
Automatically closed -- issue fixed for 2 weeks with no activity.
Drupal is a registered trademark of Dries Buytaert.