diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c index 111850184660..7d54b824ed6f 100644 --- a/bin/sh/histedit.c +++ b/bin/sh/histedit.c @@ -1,4 +1,4 @@ -/* $NetBSD: histedit.c,v 1.18 1998/04/07 10:16:04 fair Exp $ */ +/* $NetBSD: histedit.c,v 1.19 1998/05/20 00:29:26 christos Exp $ */ /*- * Copyright (c) 1993 @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: histedit.c,v 1.18 1998/04/07 10:16:04 fair Exp $"); +__RCSID("$NetBSD: histedit.c,v 1.19 1998/05/20 00:29:26 christos Exp $"); #endif #endif /* not lint */ @@ -111,7 +111,7 @@ histedit() el_out = fdopen(2, "w"); if (el_in == NULL || el_out == NULL) goto bad; - el = el_init(arg0, el_in, el_out); + el = el_init(arg0, el_in, el_out, el_out); if (el != NULL) { if (hist) el_set(el, EL_HIST, history, hist); @@ -159,7 +159,7 @@ sethistsize(hs) if (hs == NULL || *hs == '\0' || (histsize = atoi(hs)) < 0) histsize = 100; - history(hist, &he, H_SETMAXSIZE, histsize); + history(hist, &he, H_SETSIZE, histsize); } } diff --git a/bin/sh/input.c b/bin/sh/input.c index e642fb0ed9f1..142ce02b2397 100644 --- a/bin/sh/input.c +++ b/bin/sh/input.c @@ -1,4 +1,4 @@ -/* $NetBSD: input.c,v 1.29 1998/03/29 04:41:44 mrg Exp $ */ +/* $NetBSD: input.c,v 1.30 1998/05/20 00:30:20 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -41,7 +41,7 @@ #if 0 static char sccsid[] = "@(#)input.c 8.3 (Berkeley) 6/9/95"; #else -__RCSID("$NetBSD: input.c,v 1.29 1998/03/29 04:41:44 mrg Exp $"); +__RCSID("$NetBSD: input.c,v 1.30 1998/05/20 00:30:20 christos Exp $"); #endif #endif /* not lint */ @@ -98,6 +98,9 @@ struct parsefile { }; +#ifndef SMALL +int lastevent = 0; /* last event number */ +#endif int plinno = 1; /* input line number */ MKINIT int parsenleft; /* copy of parsefile->nleft */ MKINIT int parselleft; /* copy of parsefile->lleft */ @@ -298,8 +301,19 @@ check: if (parsefile->fd == 0 && hist && something) { HistEvent he; INTOFF; - history(hist, &he, - whichprompt == 1 ? H_ENTER : H_ADD, parsenextc); + if (whichprompt == 1) { + history(hist, &he, H_ENTER, parsenextc); + lastevent = he.num; + } + else { + /* + * In case the user moved around in the history buffer, + * we reset to the last full line event. + */ + if (history(hist, &he, H_SET, lastevent) == -1) + error("History: %d: `%s'", lastevent, he.str); + history(hist, &he, H_ADD, parsenextc); + } INTON; } #endif