From ebb51c4f5e0fc01bae7a60083cfd3400ea39af26 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Wed, 12 May 2021 10:02:02 +0200 Subject: [PATCH] Disable -a mode without readline --- sapi/cli/php_cli.c | 18 ++++++------------ sapi/cli/tests/009.phpt | 2 ++ sapi/cli/tests/012-2.phpt | 2 ++ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/sapi/cli/php_cli.c b/sapi/cli/php_cli.c index e0a1191c3de3e..a6c47e185909b 100644 --- a/sapi/cli/php_cli.c +++ b/sapi/cli/php_cli.c @@ -488,11 +488,7 @@ static void php_cli_usage(char *argv0) " %s [options] -- [args...]\n" " %s [options] -a\n" "\n" -#if (defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)) && !defined(COMPILE_DL_READLINE) - " -a Run as interactive shell\n" -#else - " -a Run interactively\n" -#endif + " -a Run as interactive shell (requires readline extension)\n" " -c | Look for php.ini file in this directory\n" " -n No configuration (ini) files will be used\n" " -d foo[=bar] Define INI entry foo with value 'bar'\n" @@ -694,6 +690,10 @@ static int do_cli(int argc, char **argv) /* {{{ */ switch (c) { case 'a': /* interactive mode */ + if (!cli_shell_callbacks.cli_shell_run) { + param_error = "Interactive shell (-a) requires the readline extension.\n"; + break; + } if (!interactive) { if (behavior != PHP_MODE_STANDARD) { param_error = param_mode_conflict; @@ -874,13 +874,7 @@ static int do_cli(int argc, char **argv) /* {{{ */ #endif if (interactive) { - if (cli_shell_callbacks.cli_shell_run) { - printf("Interactive shell\n\n"); - } else { - printf("Interactive mode enabled\n\n"); - /* Treat as non-interactive apart from the stdin input */ - interactive = false; - } + printf("Interactive shell\n\n"); fflush(stdout); } diff --git a/sapi/cli/tests/009.phpt b/sapi/cli/tests/009.phpt index c110966458326..904f680c7f378 100644 --- a/sapi/cli/tests/009.phpt +++ b/sapi/cli/tests/009.phpt @@ -1,5 +1,7 @@ --TEST-- using invalid combinations of cmdline options +--EXTENSIONS-- +readline --SKIPIF-- --FILE-- diff --git a/sapi/cli/tests/012-2.phpt b/sapi/cli/tests/012-2.phpt index da73fa9b26f22..8ef97595691e3 100644 --- a/sapi/cli/tests/012-2.phpt +++ b/sapi/cli/tests/012-2.phpt @@ -1,5 +1,7 @@ --TEST-- more invalid arguments and error messages +--EXTENSIONS-- +readline --SKIPIF-- --FILE--