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

PATCH: History and precmd



Does anybody know of a problem with the following?  I suddenly found myself
wanting the history number for `print -P %h` and the value of the $history
assoc to be up-to-date during precmd().

I used stophist = 3 because it wasn't being used for anything else.  If
there's some reason that all current values of stophist are powers of 2,
I couldn't discover it.

Index: Src/init.c
===================================================================
@@ -106,12 +106,16 @@
     for (;;) {
 	freeheap();
 	errflag = 0;
+	hbegin(1);		/* init history mech        */
 	if (isset(SHINSTDIN)) {
 	    setblock_stdin();
-	    if (interact)
+	    if (interact) {
+	        int hstop = stophist;
+		stophist = 3;
 		preprompt();
+		stophist = hstop;
+	    }
 	}
-	hbegin(1);		/* init history mech        */
 	intr();			/* interrupts on            */
 	lexinit();              /* initialize lexical state */
 	if (!(prog = parse_event())) {	/* if we couldn't parse a list */

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



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