function _drush_core_eval_shebang_script
8.0.x core.drush.inc | _drush_core_eval_shebang_script($script_filename) |
6.x core.drush.inc | _drush_core_eval_shebang_script($script_filename) |
7.x core.drush.inc | _drush_core_eval_shebang_script($script_filename) |
4.x core.drush.inc | _drush_core_eval_shebang_script($script_filename) |
5.x core.drush.inc | _drush_core_eval_shebang_script($script_filename) |
master core.drush.inc | _drush_core_eval_shebang_script($script_filename) |
Evaluate a script that begins with #!drush php-script
1 call to _drush_core_eval_shebang_script()
- drush_core_php_script in commands/
core/ core.drush.inc - Command callback. Runs "naked" php scripts and drush "shebang" scripts ("#!/usr/bin/env drush").
File
- commands/
core/ core.drush.inc, line 1161 - Core drush commands.
Code
function _drush_core_eval_shebang_script($script_filename) {
$found = FALSE;
$fp = fopen($script_filename, "r");
if ($fp !== FALSE) {
$line = fgets($fp);
if (_drush_is_drush_shebang_line($line)) {
$first_script_line = '';
while ($line = fgets($fp)) {
$line = trim($line);
if ($line == '<?php') {
$found = TRUE;
break;
}
elseif (!empty($line)) {
$first_script_line = $line . "\n";
break;
}
}
$script = stream_get_contents($fp);
// Pop off the first two arguments, the
// command (php-script) and the path to
// the script to execute, as a service
// to the script.
eval($first_script_line . $script);
$found = TRUE;
}
fclose($fp);
}
return $found;
}