summaryrefslogtreecommitdiff
path: root/sapi/cli/php_cli.c
diff options
context:
space:
mode:
authorEdin Kadribasic <edink@php.net>2002-03-08 09:47:52 +0000
committerEdin Kadribasic <edink@php.net>2002-03-08 09:47:52 +0000
commit61071e6b7b9b841dfb820c311856d8ceb32240ae (patch)
treeeb89c022a2ab6ba51bcb65ba3a30639feef39b76 /sapi/cli/php_cli.c
parent0cf6de6fcb7a6b40915b88d7451cb463e8452654 (diff)
downloadphp-git-61071e6b7b9b841dfb820c311856d8ceb32240ae.tar.gz
@- Added -r option to the CLI version of PHP which executes a piece of PHP
@ code directly from the commmand line. (Edin)
Diffstat (limited to 'sapi/cli/php_cli.c')
-rw-r--r--sapi/cli/php_cli.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index 4cc228a7b4..e607973c35 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -81,11 +81,12 @@
#define PHP_MODE_INDENT 3
#define PHP_MODE_LINT 4
#define PHP_MODE_STRIP 5
+#define PHP_MODE_CLI_DIRECT 6
extern char *ap_php_optarg;
extern int ap_php_optind;
-#define OPTSTRING "aCc:d:ef:g:hilmnqsw?vz:"
+#define OPTSTRING "aCc:d:ef:g:hilmnqr:sw?vz:"
static int _print_module_info(zend_module_entry *module, void *arg TSRMLS_DC)
{
@@ -252,6 +253,7 @@ static void php_cli_usage(char *argv0)
" -l Syntax check only (lint)\n"
" -m Show compiled in modules\n"
" -i PHP information\n"
+ " -r <code> Run PHP <code>\n"
" -h This help\n", prog);
}
/* }}} */
@@ -302,6 +304,8 @@ int main(int argc, char *argv[])
char *script_file=NULL;
zend_llist global_vars;
int interactive=0;
+ char *exec_direct=NULL;
+ char *compiled_string_description;
/* end of temporary locals */
#ifdef ZTS
zend_compiler_globals *compiler_globals;
@@ -475,6 +479,11 @@ int main(int argc, char *argv[])
case 's': /* generate highlighted HTML from source */
behavior=PHP_MODE_HIGHLIGHT;
break;
+
+ case 'r': /* generate highlighted HTML from source */
+ behavior=PHP_MODE_CLI_DIRECT;
+ exec_direct=ap_php_optarg;
+ break;
case 'v': /* show php version & quit */
no_headers = 1;
@@ -595,6 +604,12 @@ int main(int argc, char *argv[])
return SUCCESS;
break;
#endif
+ case PHP_MODE_CLI_DIRECT:
+ compiled_string_description = zend_make_compiled_string_description("Command line code" TSRMLS_CC);
+ if (zend_eval_string(exec_direct, NULL, compiled_string_description TSRMLS_CC) == FAILURE) {
+ exit_status=254;
+ }
+ efree(compiled_string_description);
}
php_request_shutdown((void *) 0);