Skip to content

Commit b32d505

Browse files
committed
Re-add local console check
1 parent 1962bc6 commit b32d505

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

sapi/phpdbg/phpdbg_cmd.c

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -745,22 +745,30 @@ PHPDBG_API char *phpdbg_read_input(const char *buffered) /* {{{ */
745745
if ((PHPDBG_G(flags) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING)) != PHPDBG_IS_STOPPING) {
746746
if (buffered == NULL) {
747747
#ifdef HAVE_PHPDBG_READLINE
748-
char *cmd = readline(phpdbg_get_prompt());
749-
PHPDBG_G(last_was_newline) = 1;
748+
/* note: EOF makes readline write prompt again in local console mode
749+
and ignored if compiled without readline */
750+
if (!isatty(PHPDBG_G(io)[PHPDBG_STDIN].fd)) {
751+
#endif
752+
char buf[PHPDBG_MAX_CMD];
753+
phpdbg_write("%s", phpdbg_get_prompt());
754+
phpdbg_consume_stdin_line(buf);
755+
buffer = estrdup(buf);
750756

751-
if (!cmd) {
752-
PHPDBG_G(flags) |= PHPDBG_IS_QUITTING;
753-
zend_bailout();
754-
}
757+
#ifdef HAVE_PHPDBG_READLINE
758+
759+
} else {
760+
char *cmd = readline(phpdbg_get_prompt());
761+
PHPDBG_G(last_was_newline) = 1;
762+
763+
if (!cmd) {
764+
PHPDBG_G(flags) |= PHPDBG_IS_QUITTING;
765+
zend_bailout();
766+
}
755767

756-
add_history(cmd);
757-
buffer = estrdup(cmd);
758-
free(cmd);
759-
#else
760-
char buf[PHPDBG_MAX_CMD];
761-
phpdbg_write("%s", phpdbg_get_prompt());
762-
phpdbg_consume_stdin_line(buf);
763-
buffer = estrdup(buf);
768+
add_history(cmd);
769+
buffer = estrdup(cmd);
770+
free(cmd);
771+
}
764772
#endif
765773
} else {
766774
buffer = estrdup(buffered);

0 commit comments

Comments
 (0)