File tree Expand file tree Collapse file tree 1 file changed +25
-9
lines changed Expand file tree Collapse file tree 1 file changed +25
-9
lines changed Original file line number Diff line number Diff line change 2323#include "phpdbg_prompt.h"
2424#include "phpdbg_io.h"
2525
26+ #ifdef HAVE_UNISTD_H
27+ # include <unistd.h>
28+ #endif
29+
2630ZEND_EXTERN_MODULE_GLOBALS (phpdbg )
2731
2832static inline const char * phpdbg_command_name (const phpdbg_command_t * command , char * buffer ) {
@@ -745,17 +749,29 @@ PHPDBG_API char *phpdbg_read_input(const char *buffered) /* {{{ */
745749 if ((PHPDBG_G (flags ) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING )) != PHPDBG_IS_STOPPING ) {
746750 if (buffered == NULL ) {
747751#ifdef HAVE_PHPDBG_READLINE
748- char * cmd = readline (phpdbg_get_prompt ());
749- PHPDBG_G (last_was_newline ) = 1 ;
752+ # ifdef HAVE_UNISTD_H
753+ /* EOF makes readline write prompt again in local console mode and
754+ ignored if compiled without readline integration. */
755+ if (!isatty (PHPDBG_G (io )[PHPDBG_STDIN ].fd )) {
756+ char buf [PHPDBG_MAX_CMD ];
757+ phpdbg_write ("%s" , phpdbg_get_prompt ());
758+ phpdbg_consume_stdin_line (buf );
759+ buffer = estrdup (buf );
760+ } else
761+ # endif
762+ {
763+ char * cmd = readline (phpdbg_get_prompt ());
764+ PHPDBG_G (last_was_newline ) = 1 ;
765+
766+ if (!cmd ) {
767+ PHPDBG_G (flags ) |= PHPDBG_IS_QUITTING ;
768+ zend_bailout ();
769+ }
750770
751- if (! cmd ) {
752- PHPDBG_G ( flags ) |= PHPDBG_IS_QUITTING ;
753- zend_bailout ( );
771+ add_history ( cmd );
772+ buffer = estrdup ( cmd ) ;
773+ free ( cmd );
754774 }
755-
756- add_history (cmd );
757- buffer = estrdup (cmd );
758- free (cmd );
759775#else
760776 char buf [PHPDBG_MAX_CMD ];
761777 phpdbg_write ("%s" , phpdbg_get_prompt ());
You can’t perform that action at this time.
0 commit comments