about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWayne Davison <wayned@users.sourceforge.net>2001-04-11 05:26:26 +0000
committerWayne Davison <wayned@users.sourceforge.net>2001-04-11 05:26:26 +0000
commite3e22f715c9fabc70de730347858197a0bda28bd (patch)
tree5666861b3a6a756962c73cff377a2f2d59df269d
parentca3f1a3b79eb873ff01eb55959799487f6cc9936 (diff)
downloadzsh-e3e22f715c9fabc70de730347858197a0bda28bd.tar.gz
zsh-e3e22f715c9fabc70de730347858197a0bda28bd.tar.xz
zsh-e3e22f715c9fabc70de730347858197a0bda28bd.zip
Fixed a bug where the call to function "preexec" might pass the wrong
history line.  Added two extra args to preexec to give the user more
info on the command that is about to be executed.
-rw-r--r--Src/init.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/Src/init.c b/Src/init.c
index a0c06aa63..3da057de9 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -135,15 +135,23 @@ loop(int toplevel, int justonce)
 	    if (toplevel && (preprog = getshfunc("preexec")) != &dummy_eprog) {
 		LinkList args;
 		int osc = sfcontext;
+		char *cmdstr;
 
 		args = znewlinklist();
 		zaddlinknode(args, "preexec");
-		if (hist_ring)
+		/* If curline got dumped from the history, we don't know
+		 * what the user typed. */
+		if (hist_ring && curline.histnum == curhist)
 		    zaddlinknode(args, hist_ring->text);
+		else
+		    zaddlinknode(args, "");
+		zaddlinknode(args, getjobtext(prog, NULL));
+		zaddlinknode(args, cmdstr = getpermtext(prog, NULL));
 
 		sfcontext = SFC_HOOK;
 		doshfunc("preexec", preprog, args, 0, 1);
 		sfcontext = osc;
+		zsfree(cmdstr);
 		freelinklist(args, (FreeFunc) NULL);
 		errflag = 0;
 	    }