summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortjr <tjr@FreeBSD.org>2002-06-02 08:27:04 +0000
committertjr <tjr@FreeBSD.org>2002-06-02 08:27:04 +0000
commit0a9f255d036d501db5a90855a6fc8b14c86b0435 (patch)
treec98a62dd8df95205d8d8047a07210338ca305825
parent6c9e59ad0036cf371711ed760fde503eb6ce580e (diff)
downloadFreeBSD-src-0a9f255d036d501db5a90855a6fc8b14c86b0435.zip
FreeBSD-src-0a9f255d036d501db5a90855a6fc8b14c86b0435.tar.gz
Adding an entry to the history with H_ENTER moves libedit's internal
history cursor. Reset the cursor after adding the entry to the history when doing ``fc -s'' so the output is correct.
-rw-r--r--bin/sh/histedit.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/bin/sh/histedit.c b/bin/sh/histedit.c
index 453c9a6..2d922be 100644
--- a/bin/sh/histedit.c
+++ b/bin/sh/histedit.c
@@ -183,6 +183,7 @@ histcmd(int argc, char **argv)
struct jmploc *volatile savehandler;
char editfile[PATH_MAX];
FILE *efp;
+ int oldhistnum;
#ifdef __GNUC__
/* Avoid longjmp clobbering */
(void) &editor;
@@ -361,7 +362,15 @@ histcmd(int argc, char **argv)
* XXX what about recursive and
* relative histnums.
*/
+ oldhistnum = he.num;
history(hist, &he, H_ENTER, s);
+ /*
+ * XXX H_ENTER moves the internal
+ * cursor, set it back to the current
+ * entry.
+ */
+ retval = history(hist, &he,
+ H_NEXT_EVENT, oldhistnum);
}
} else
fputs(s, efp);
OpenPOWER on IntegriCloud