Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Minor history bugfix



While I was playing around with the history code, I found an obscure bug
in the current codebase.  If you have SHARE_HISTORY on but HIST_NO_STORE
off, plus you have local-history mode set (so that you don't see foreign
commands when moving up and down in the history), and you type a second
"history" command in a row that just happens to slurp in some foreign
history in between the two, the displayed history is not quite right.

The fix is much simpler than the problem description above.  The old
code was trying to get fancy when it merged the current command with the
previously-typed one.  This patch makes it do the simple thing that will
always work right.

..wayne..

---8<------8<------8<------8<---cut here--->8------>8------>8------>8---
Index: Src/hist.c
@@ -1067,8 +1067,6 @@
 	Histent he;
 	int keepflags;

-	for (he = hist_ring; he && he->flags & hist_skip_flags;
-	     he = up_histent(he)) ;
 #ifdef DEBUG
 	/* debugging only */
 	if (chwordpos%2) {
@@ -1083,13 +1081,14 @@
 	    if (isset(HISTREDUCEBLANKS))
 		histreduceblanks();
 	}
-	if ((isset(HISTIGNOREDUPS) || isset(HISTIGNOREALLDUPS)) && he
-	 && histstrcmp(chline, he->text) == 0) {
+	if ((isset(HISTIGNOREDUPS) || isset(HISTIGNOREALLDUPS)) && hist_ring
+	 && histstrcmp(chline, hist_ring->text) == 0) {
 	    /* This history entry compares the same as the previous.
 	     * In case minor changes were made, we overwrite the
 	     * previous one with the current one.  This also gets the
 	     * timestamp right.  Perhaps, preserve the HIST_OLD flag.
 	     */
+	    he = hist_ring;
 	    keepflags = he->flags & HIST_OLD; /* Avoid re-saving */
 	    freehistdata(he, 0);
 	    curline.histnum = curhist;
---8<------8<------8<------8<---cut here--->8------>8------>8------>8---



Messages sorted by: Reverse Date, Date, Thread, Author