You are here

function drush_computing_eval in Drupal Computing 7

Same name and namespace in other branches
  1. 7.2 computing.drush.inc \drush_computing_eval()

File

./computing.drush.inc, line 197
Drupal Hybrid Computing drush interface. To use this, please install Drush at http://drupal.org/project/drush

Code

function drush_computing_eval($code) {

  // read STDIN followed the example of drush_core_php_script()
  $php = $code == '-' ? stream_get_contents(STDIN) : $code;

  // todo: might need to encode/decode here.
  $result = eval($php);

  //drush_print(serialize($result));
  $json = drush_json_encode($result);
  drush_print("JSON output: \n{$json}");
  drush_print_pipe($json . ' ');

  // the returned value would be saved in $results['object']
  return $result;
}