implement duplicate ignoring in the history, also requested by asarch,

and wanted by me for a while
This commit is contained in:
tg 2008-09-30 17:58:49 +00:00
parent f53a8196e4
commit 563d4b5b19

9
lex.c
View File

@ -2,7 +2,7 @@
#include "sh.h" #include "sh.h"
__RCSID("$MirOS: src/bin/mksh/lex.c,v 1.68 2008/09/30 17:49:26 tg Exp $"); __RCSID("$MirOS: src/bin/mksh/lex.c,v 1.69 2008/09/30 17:58:49 tg Exp $");
/* /*
* states while lexing word * states while lexing word
@ -1242,9 +1242,16 @@ getsc_line(Source *s)
} else if (interactive) { } else if (interactive) {
char *p = Xstring(s->xs, xp); char *p = Xstring(s->xs, xp);
if (*p && (cur_prompt != PS1 || !ctype(*p, C_IFS | C_IFSWS))) { if (*p && (cur_prompt != PS1 || !ctype(*p, C_IFS | C_IFSWS))) {
if ((p = strchr(p, '\n')) != NULL)
*p = '\0';
/* ignore dups */
if (strcmp(s->str, *histptr)) {
s->line++; s->line++;
histsave(s->line, s->str, true); histsave(s->line, s->str, true);
} }
if (p != NULL)
*p = '\n';
}
} }
if (interactive) if (interactive)
set_prompt(PS2, NULL); set_prompt(PS2, NULL);