com php-src: Rework automatic interactive cli activation: sapi/cli/php_cli.c
| From: | Anatol Belski | Date: | Thu, 03 Aug 2017 09:23:50 +0000 |
| Subject: | com php-src: Rework automatic interactive cli activation: sapi/cli/php_cli.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-98933@lists.php.net to get a copy of this message | ||
Commit: 93c2c56a1bc6a6184ce92dd0d9f3702c8ed00444
Author: Anatol Belski <ab@php.net> Thu, 3 Aug 2017 11:23:50 +0200
Parents: 39f0e810c94cdc73aca508f16cf94800fd216f84
Branches: PHP-7.2 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=93c2c56a1bc6a6184ce92dd0d9f3702c8ed00444
Log:
Rework automatic interactive cli activation
There are still systems delivering buggy console info. If a file was
passed, obviously no interaction is meant.
Changed paths:
M sapi/cli/php_cli.c
Diff:
diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c
index d1fa6a6..52055c9 100644
--- a/sapi/cli/php_cli.c
+++ b/sapi/cli/php_cli.c
@@ -674,11 +674,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
char *exec_direct=NULL, *exec_run=NULL, *exec_begin=NULL, *exec_end=NULL;
char *arg_free=NULL, **arg_excp=&arg_free;
char *script_file=NULL, *translated_path = NULL;
-#if defined(PHP_WIN32) && !defined(PHP_CLI_WIN32_NO_CONSOLE) && (HAVE_LIBREADLINE
|| HAVE_LIBEDIT) && !defined(COMPILE_DL_READLINE)
- int interactive = php_win32_console_is_own();
-#else
int interactive=0;
-#endif
int lineno = 0;
const char *param_error=NULL;
int hide_argv = 0;
@@ -918,6 +914,20 @@ static int do_cli(int argc, char **argv) /* {{{ */
goto err;
}
+#if defined(PHP_WIN32) && !defined(PHP_CLI_WIN32_NO_CONSOLE) && (HAVE_LIBREADLINE
|| HAVE_LIBEDIT) && !defined(COMPILE_DL_READLINE)
+ if (!interactive) {
+ /* The -a option was not passed. If there is no file, it could
+ still make sense to run interactively. The presense of a file
+ is essential to mitigate buggy console info. */
+ interactive = php_win32_console_is_own() &&
+ !(script_file ||
+ argc > php_optind && behavior!=PHP_MODE_CLI_DIRECT &&
+ behavior!=PHP_MODE_PROCESS_STDIN &&
+ strcmp(argv[php_optind-1],"--")
+ );
+ }
+#endif
+
if (interactive) {
#if (HAVE_LIBREADLINE || HAVE_LIBEDIT) && !defined(COMPILE_DL_READLINE)
printf("Interactive shell\n\n");