@@ -1108,6 +1108,7 @@ static void sapi_cli_register_variables(zval *track_vars_array) /* {{{ */
11081108
11091109static void * execute_script_cli (void * arg ) {
11101110 void * exit_status ;
1111+ bool eval = (bool )arg ;
11111112
11121113 /*
11131114 * The SAPI name "cli" is hardcoded into too many programs... let's usurp it.
@@ -1120,11 +1121,16 @@ static void *execute_script_cli(void *arg) {
11201121
11211122 cli_register_file_handles (false);
11221123 zend_first_try {
1123- zend_file_handle file_handle ;
1124- zend_stream_init_filename (& file_handle , cli_script );
1124+ if (eval ) {
1125+ /* evaluate the cli_script as literal PHP code (php-cli -r "...") */
1126+ zend_eval_string_ex (cli_script , NULL , "Command line code" , 1 );
1127+ } else {
1128+ zend_file_handle file_handle ;
1129+ zend_stream_init_filename (& file_handle , cli_script );
11251130
1126- CG (skip_shebang ) = 1 ;
1127- php_execute_script (& file_handle );
1131+ CG (skip_shebang ) = 1 ;
1132+ php_execute_script (& file_handle );
1133+ }
11281134 }
11291135 zend_end_try ();
11301136
@@ -1135,7 +1141,8 @@ static void *execute_script_cli(void *arg) {
11351141 return exit_status ;
11361142}
11371143
1138- int frankenphp_execute_script_cli (char * script , int argc , char * * argv ) {
1144+ int frankenphp_execute_script_cli (char * script , int argc , char * * argv ,
1145+ bool eval ) {
11391146 pthread_t thread ;
11401147 int err ;
11411148 void * exit_status ;
@@ -1148,7 +1155,7 @@ int frankenphp_execute_script_cli(char *script, int argc, char **argv) {
11481155 * Start the script in a dedicated thread to prevent conflicts between Go and
11491156 * PHP signal handlers
11501157 */
1151- err = pthread_create (& thread , NULL , execute_script_cli , NULL );
1158+ err = pthread_create (& thread , NULL , execute_script_cli , ( void * ) eval );
11521159 if (err != 0 ) {
11531160 return err ;
11541161 }
0 commit comments