@@ -607,7 +607,6 @@ static int do_cli(int argc, char **argv) /* {{{ */
607607 int behavior = PHP_MODE_STANDARD ;
608608 char * reflection_what = NULL ;
609609 volatile int request_started = 0 ;
610- volatile int exit_status = 0 ;
611610 char * php_optarg = NULL , * orig_optarg = NULL ;
612611 int php_optind = 1 , orig_optind = 1 ;
613612 char * exec_direct = NULL , * exec_run = NULL , * exec_begin = NULL , * exec_end = NULL ;
@@ -631,7 +630,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
631630 request_started = 1 ;
632631 php_print_info (0xFFFFFFFF );
633632 php_output_end_all ();
634- exit_status = (c == '?' && argc > 1 && !strchr (argv [1 ], c ));
633+ EG ( exit_status ) = (c == '?' && argc > 1 && !strchr (argv [1 ], c ));
635634 goto out ;
636635
637636 case 'v' : /* show php version & quit */
@@ -673,7 +672,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
673672 print_extensions ();
674673 php_printf ("\n" );
675674 php_output_end_all ();
676- exit_status = 0 ;
675+ EG ( exit_status ) = 0 ;
677676 goto out ;
678677
679678 default :
@@ -848,7 +847,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
848847
849848 if (param_error ) {
850849 PUTS (param_error );
851- exit_status = 1 ;
850+ EG ( exit_status ) = 1 ;
852851 goto err ;
853852 }
854853
@@ -946,15 +945,14 @@ static int do_cli(int argc, char **argv) /* {{{ */
946945 }
947946
948947 if (interactive && cli_shell_callbacks .cli_shell_run ) {
949- exit_status = cli_shell_callbacks .cli_shell_run ();
948+ EG ( exit_status ) = cli_shell_callbacks .cli_shell_run ();
950949 } else {
951950 php_execute_script (& file_handle );
952- exit_status = EG (exit_status );
953951 }
954952 break ;
955953 case PHP_MODE_LINT :
956- exit_status = php_lint_script (& file_handle );
957- if (exit_status == SUCCESS ) {
954+ EG ( exit_status ) = php_lint_script (& file_handle );
955+ if (EG ( exit_status ) == SUCCESS ) {
958956 zend_printf ("No syntax errors detected in %s\n" , file_handle .filename );
959957 } else {
960958 zend_printf ("Errors parsing %s\n" , file_handle .filename );
@@ -980,7 +978,6 @@ static int do_cli(int argc, char **argv) /* {{{ */
980978 case PHP_MODE_CLI_DIRECT :
981979 cli_register_file_handles ();
982980 zend_eval_string_ex (exec_direct , NULL , "Command line code" , 1 );
983- exit_status = EG (exit_status );
984981 break ;
985982
986983 case PHP_MODE_PROCESS_STDIN :
@@ -991,10 +988,10 @@ static int do_cli(int argc, char **argv) /* {{{ */
991988
992989 cli_register_file_handles ();
993990
994- if (exec_begin && zend_eval_string_ex ( exec_begin , NULL , "Command line begin code" , 1 ) == FAILURE ) {
995- exit_status = EG ( exit_status );
991+ if (exec_begin ) {
992+ zend_eval_string_ex ( exec_begin , NULL , "Command line begin code" , 1 );
996993 }
997- while (exit_status == SUCCESS && (input = php_stream_gets (s_in_process , NULL , 0 )) != NULL ) {
994+ while (EG ( exit_status ) == SUCCESS && (input = php_stream_gets (s_in_process , NULL , 0 )) != NULL ) {
998995 len = strlen (input );
999996 while (len > 0 && len -- && (input [len ]== '\n' || input [len ]== '\r' )) {
1000997 input [len ] = '\0' ;
@@ -1004,24 +1001,21 @@ static int do_cli(int argc, char **argv) /* {{{ */
10041001 ZVAL_LONG (& argi , ++ index );
10051002 zend_hash_str_update (& EG (symbol_table ), "argi" , sizeof ("argi" )- 1 , & argi );
10061003 if (exec_run ) {
1007- if (zend_eval_string_ex (exec_run , NULL , "Command line run code" , 1 ) == FAILURE ) {
1008- exit_status = EG (exit_status );
1009- }
1004+ zend_eval_string_ex (exec_run , NULL , "Command line run code" , 1 );
10101005 } else {
10111006 if (script_file ) {
10121007 if (cli_seek_file_begin (& file_handle , script_file ) != SUCCESS ) {
1013- exit_status = 1 ;
1008+ EG ( exit_status ) = 1 ;
10141009 } else {
10151010 CG (skip_shebang ) = 1 ;
10161011 php_execute_script (& file_handle );
1017- exit_status = EG (exit_status );
10181012 }
10191013 }
10201014 }
10211015 efree (input );
10221016 }
1023- if (exec_end && zend_eval_string_ex ( exec_end , NULL , "Command line end code" , 1 ) == FAILURE ) {
1024- exit_status = EG ( exit_status );
1017+ if (exec_end ) {
1018+ zend_eval_string_ex ( exec_end , NULL , "Command line end code" , 1 );
10251019 }
10261020
10271021 break ;
@@ -1091,7 +1085,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
10911085 display_ini_entries (NULL );
10921086 } else {
10931087 zend_printf ("Extension '%s' not present.\n" , reflection_what );
1094- exit_status = 1 ;
1088+ EG ( exit_status ) = 1 ;
10951089 }
10961090 } else {
10971091 php_info_print_module (module );
@@ -1119,14 +1113,11 @@ static int do_cli(int argc, char **argv) /* {{{ */
11191113 if (translated_path ) {
11201114 free (translated_path );
11211115 }
1122- if (exit_status == 0 ) {
1123- exit_status = EG (exit_status );
1124- }
1125- return exit_status ;
1116+ return EG (exit_status );
11261117err :
11271118 sapi_deactivate ();
11281119 zend_ini_deactivate ();
1129- exit_status = 1 ;
1120+ EG ( exit_status ) = 1 ;
11301121 goto out ;
11311122}
11321123/* }}} */
0 commit comments