com php-src: Fix bug #67496 Save command history when exiting interactive shell with control-c: NEWS ext/readline/readline_cli.c
| From: | Johannes Schlüter | Date: | Thu, 24 Jul 2014 15:58:39 +0000 |
| Subject: | com php-src: Fix bug #67496 Save command history when exiting interactive shell with control-c: NEWS ext/readline/readline_cli.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-79582@lists.php.net to get a copy of this message | ||
Commit: d491b2f916d061666d9ff1cb5bdc484961b82db0
Author: Dmitry Saprykin <saprykin.dmitry@gmail.com> Thu, 24 Jul 2014 17:58:39 +0200
Committer: Johannes Schlüter <johannes@php.net> Thu, 24 Jul 2014 17:58:39 +0200
Parents: 71d3a69425449972f4efdf7228c6f7e49e090755
Branches: PHP-5.4 PHP-5.5 PHP-5.6 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d491b2f916d061666d9ff1cb5bdc484961b82db0
Log:
Fix bug #67496 Save command history when exiting interactive shell with control-c
Bugs:
https://bugs.php.net/67496
Changed paths:
M NEWS
M ext/readline/readline_cli.c
Diff:
diff --git a/NEWS b/NEWS
index c4592a3..89d41ab 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,8 @@ PHP NEWS
- Readline:
. Fixed bug #55496 (Interactive mode doesn't force a newline before the
prompt). (Bob, Johannes)
+ . Fixed bug #67496 (Save command history when exiting interactive shell
+ with control-c). (Dmitry Saprykin, Johannes)
?? ??? 2014, PHP 5.4.31
diff --git a/ext/readline/readline_cli.c b/ext/readline/readline_cli.c
index 9655777..9c27acb 100644
--- a/ext/readline/readline_cli.c
+++ b/ext/readline/readline_cli.c
@@ -590,6 +590,7 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
char *code = emalloc(size);
char *prompt = cli_get_prompt("php", '>' TSRMLS_CC);
char *history_file;
+ int history_lines_to_write = 0;
if (PG(auto_prepend_file) && PG(auto_prepend_file)[0]) {
zend_file_handle *prepend_file_p;
@@ -654,6 +655,7 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
if (*line) {
add_history(line);
+ history_lines_to_write += 1;
}
free(line);
@@ -663,6 +665,15 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
continue;
}
+ if (history_lines_to_write) {
+#if HAVE_LIBEDIT
+ write_history(history_file);
+#else
+ append_history(history_lines_to_write, history_file);
+#endif
+ history_lines_to_write = 0;
+ }
+
zend_try {
zend_eval_stringl(code, pos, NULL, "php shell code" TSRMLS_CC);
} zend_end_try();
@@ -684,7 +695,6 @@ static int readline_shell_run(TSRMLS_D) /* {{{ */
php_last_char = '\0';
}
- write_history(history_file);
free(history_file);
efree(code);
efree(prompt);