From 5aae01104f88f98f42fd997d360757651f7cc919 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Wed, 12 Oct 2016 20:11:51 +0200 Subject: Add stdin command and -s command line parameter to phpdbg This allows reading the initial script file from stdin instead of being forced to put the script into a file in order to run it with phpdbg. Especially important for programmatic execution of phpdbg. Also adding tests/include_once.phpt and tests/set_exception_handler.phpt as I seem to have forgotten to git add them sometime long ago... --- sapi/phpdbg/phpdbg_help.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'sapi/phpdbg/phpdbg_help.c') diff --git a/sapi/phpdbg/phpdbg_help.c b/sapi/phpdbg/phpdbg_help.c index a7385df21e..ce1d8d9e90 100644 --- a/sapi/phpdbg/phpdbg_help.c +++ b/sapi/phpdbg/phpdbg_help.c @@ -338,6 +338,7 @@ phpdbg_help_text_t phpdbg_help_text[] = { "**Starting and Stopping Execution**" CR " **exec** set execution context" CR +" **stdin** set executing script from stdin" CR " **run** attempt execution" CR " **step** continue execution until other line is reached" CR " **continue** continue execution" CR @@ -386,6 +387,7 @@ phpdbg_help_text_t phpdbg_help_text[] = { " **-rr** Run execution context and quit after execution (not respecting breakpoints)" CR " **-e** Generate extended information for debugger/profiler" CR " **-E** Enable step through eval, careful!" CR +" **-s** **-s=**, **-s**=foo Read code to execute from stdin with an optional delimiter" CR " **-S** **-S**cli Override SAPI name, careful!" CR " **-l** **-l**4000 Setup remote console ports" CR " **-a** **-a**192.168.0.3 Setup remote console bind address" CR @@ -396,6 +398,13 @@ phpdbg_help_text_t phpdbg_help_text[] = { " **--** **--** arg1 arg2 Use to delimit phpdbg arguments and php $argv; append any $argv " "argument after it" CR CR +"**Reading from stdin**" CR CR + +"The **-s** option allows inputting a script to execute directly from stdin. The given delimiter " +"(\"foo\" in the example) needs to be specified at the end of the input on its own line, followed by " +"a line break. If **-rr** has been specified, it is allowed to omit the delimiter (**-s=**) and " +"it will read until EOF. See also the help entry for the **stdin** command." CR CR + "**Remote Console Mode**" CR CR "This mode is enabled by specifying the **-a** option. Phpdbg will bind only to the loopback " @@ -634,6 +643,21 @@ phpdbg_help_text_t phpdbg_help_text[] = { " Set the execution context to **/tmp/script.php**" }, +{"stdin", +"The **stdin** command takes a string serving as delimiter. It will then read all the input from " +"stdin until encountering the given delimiter on a standalone line. It can also be passed at " +"startup using the **-s=** command line option (the delimiter then is optional if **-rr** is " +"also passed - in that case it will just read until EOF)." CR +"This input will be then compiled as PHP code and set as execution context." CR CR + +"**Example**" CR CR + +" $P stdin foo" CR +"