From 563d4b5b1974d551c5f917c794355d844450c156 Mon Sep 17 00:00:00 2001 From: tg Date: Tue, 30 Sep 2008 17:58:49 +0000 Subject: [PATCH] implement duplicate ignoring in the history, also requested by asarch, and wanted by me for a while --- lex.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lex.c b/lex.c index d3ee266..21790bc 100644 --- a/lex.c +++ b/lex.c @@ -2,7 +2,7 @@ #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 @@ -1242,8 +1242,15 @@ getsc_line(Source *s) } else if (interactive) { char *p = Xstring(s->xs, xp); if (*p && (cur_prompt != PS1 || !ctype(*p, C_IFS | C_IFSWS))) { - s->line++; - histsave(s->line, s->str, true); + if ((p = strchr(p, '\n')) != NULL) + *p = '\0'; + /* ignore dups */ + if (strcmp(s->str, *histptr)) { + s->line++; + histsave(s->line, s->str, true); + } + if (p != NULL) + *p = '\n'; } } if (interactive)