summaryrefslogtreecommitdiff
path: root/main/asterisk.c
diff options
context:
space:
mode:
authorWalter Doekes <walter+asterisk@wjd.nu>2013-08-22 12:28:33 +0000
committerWalter Doekes <walter+asterisk@wjd.nu>2013-08-22 12:28:33 +0000
commit28e9d3afc9d8a091206490c02a9f2999850aa9dd (patch)
tree80db2faa15f87812a2fb85098ef355c338e3a572 /main/asterisk.c
parent80edcdcc45c0ed6c9223af59b2c6961df2e7a325 (diff)
Don't store repeated commands in the editline history buffer.
The equivalent of bash HISTCONTROL=ignoredups. Review: https://reviewboard.asterisk.org/r/2775/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@397415 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/asterisk.c')
-rw-r--r--main/asterisk.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/main/asterisk.c b/main/asterisk.c
index d6a454e8b..959993147 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -3021,12 +3021,23 @@ static int ast_el_initialize(void)
static int ast_el_add_history(char *buf)
{
HistEvent ev;
+ char *stripped_buf;
- if (el_hist == NULL || el == NULL)
+ if (el_hist == NULL || el == NULL) {
ast_el_initialize();
- if (strlen(buf) > (MAX_HISTORY_COMMAND_LENGTH - 1))
+ }
+ if (strlen(buf) > (MAX_HISTORY_COMMAND_LENGTH - 1)) {
return 0;
- return (history(el_hist, &ev, H_ENTER, ast_strip(ast_strdupa(buf))));
+ }
+
+ stripped_buf = ast_strip(ast_strdupa(buf));
+
+ /* HISTCONTROL=ignoredups */
+ if (!history(el_hist, &ev, H_FIRST) && strcmp(ev.str, stripped_buf) == 0) {
+ return 0;
+ }
+
+ return history(el_hist, &ev, H_ENTER, stripped_buf);
}
static int ast_el_write_history(char *filename)