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

Re: zero elapsed time in history with certain preexec functions



On Dec 25,  2:07pm, Michael Kaminsky wrote:
}
} It appears that subscripting a variable (or indexing into a zsh array)
} inside of the preexec function causes zsh not to record the elapsed
} time/duration of the command.

A time is recorded, but it's the wrong time.

The following seems to fix it, but someone more familiar with this part
of the history mechanism should check my work: 

Index: Src/hist.c
===================================================================
diff -c -r1.31 hist.c
--- Src/hist.c	26 Nov 2007 17:38:13 -0000	1.31
+++ Src/hist.c	29 Dec 2007 18:24:06 -0000
@@ -826,7 +826,7 @@
     }
     chwordpos = 0;
 
-    if (hist_ring && !hist_ring->ftim)
+    if (hist_ring && !hist_ring->ftim && !strin)
 	hist_ring->ftim = time(NULL);
     if ((dohist == 2 || (interact && isset(SHINSTDIN))) && !strin) {
 	histactive = HA_ACTIVE;


(Revision numbers are from my local CVS repository and bear no relation
to the Sourceforce repository.)

-- 



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