Skip to content

Commit 746d736

Browse files
committed
Disable -a mode without readline
1 parent c945c39 commit 746d736

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

sapi/cli/php_cli.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -490,8 +490,6 @@ static void php_cli_usage(char *argv0)
490490
"\n"
491491
#if (defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)) && !defined(COMPILE_DL_READLINE)
492492
" -a Run as interactive shell\n"
493-
#else
494-
" -a Run interactively\n"
495493
#endif
496494
" -c <path>|<file> Look for php.ini file in this directory\n"
497495
" -n No configuration (ini) files will be used\n"
@@ -694,6 +692,10 @@ static int do_cli(int argc, char **argv) /* {{{ */
694692
switch (c) {
695693

696694
case 'a': /* interactive mode */
695+
if (!cli_shell_callbacks.cli_shell_run) {
696+
param_error = "Interactive shell (-a) requires the readline extension.\n";
697+
break;
698+
}
697699
if (!interactive) {
698700
if (behavior != PHP_MODE_STANDARD) {
699701
param_error = param_mode_conflict;
@@ -874,13 +876,7 @@ static int do_cli(int argc, char **argv) /* {{{ */
874876
#endif
875877

876878
if (interactive) {
877-
if (cli_shell_callbacks.cli_shell_run) {
878-
printf("Interactive shell\n\n");
879-
} else {
880-
printf("Interactive mode enabled\n\n");
881-
/* Treat as non-interactive apart from the stdin input */
882-
interactive = false;
883-
}
879+
printf("Interactive shell\n\n");
884880
fflush(stdout);
885881
}
886882

sapi/cli/tests/009.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
using invalid combinations of cmdline options
3+
--EXTENSIONS--
4+
readline
35
--SKIPIF--
46
<?php include "skipif.inc"; ?>
57
--FILE--

sapi/cli/tests/012-2.phpt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
--TEST--
22
more invalid arguments and error messages
3+
--EXTENSIONS--
4+
readline
35
--SKIPIF--
46
<?php include "skipif.inc"; ?>
57
--FILE--

0 commit comments

Comments
 (0)