File tree 1 file changed +25
-9
lines changed
1 file changed +25
-9
lines changed Original file line number Diff line number Diff line change 23
23
#include "phpdbg_prompt.h"
24
24
#include "phpdbg_io.h"
25
25
26
+ #ifdef HAVE_UNISTD_H
27
+ # include <unistd.h>
28
+ #endif
29
+
26
30
ZEND_EXTERN_MODULE_GLOBALS (phpdbg )
27
31
28
32
static 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) /* {{{ */
745
749
if ((PHPDBG_G (flags ) & (PHPDBG_IS_STOPPING | PHPDBG_IS_RUNNING )) != PHPDBG_IS_STOPPING ) {
746
750
if (buffered == NULL ) {
747
751
#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
+ }
750
770
751
- if (! cmd ) {
752
- PHPDBG_G ( flags ) |= PHPDBG_IS_QUITTING ;
753
- zend_bailout ( );
771
+ add_history ( cmd );
772
+ buffer = estrdup ( cmd ) ;
773
+ free ( cmd );
754
774
}
755
-
756
- add_history (cmd );
757
- buffer = estrdup (cmd );
758
- free (cmd );
759
775
#else
760
776
char buf [PHPDBG_MAX_CMD ];
761
777
phpdbg_write ("%s" , phpdbg_get_prompt ());
You can’t perform that action at this time.
0 commit comments