Skip to content

Commit 432bd11

Browse files
committed
Merge branch 'PHP-5.4' into PHP-5.5
2 parents 899b369 + d491b2f commit 432bd11

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

ext/readline/readline_cli.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,6 +590,7 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
590590
char *code = emalloc(size);
591591
char *prompt = cli_get_prompt("php", '>' TSRMLS_CC);
592592
char *history_file;
593+
int history_lines_to_write = 0;
593594

594595
if (PG(auto_prepend_file) && PG(auto_prepend_file)[0]) {
595596
zend_file_handle *prepend_file_p;
@@ -654,6 +655,7 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
654655

655656
if (*line) {
656657
add_history(line);
658+
history_lines_to_write += 1;
657659
}
658660

659661
free(line);
@@ -663,6 +665,15 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
663665
continue;
664666
}
665667

668+
if (history_lines_to_write) {
669+
#if HAVE_LIBEDIT
670+
write_history(history_file);
671+
#else
672+
append_history(history_lines_to_write, history_file);
673+
#endif
674+
history_lines_to_write = 0;
675+
}
676+
666677
zend_try {
667678
zend_eval_stringl(code, pos, NULL, "php shell code" TSRMLS_CC);
668679
} zend_end_try();
@@ -684,7 +695,6 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
684695

685696
php_last_char = '\0';
686697
}
687-
write_history(history_file);
688698
free(history_file);
689699
efree(code);
690700
efree(prompt);

0 commit comments

Comments
 (0)