From e3e22f715c9fabc70de730347858197a0bda28bd Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Wed, 11 Apr 2001 05:26:26 +0000 Subject: 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. --- Src/init.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Src') 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; } -- cgit 1.4.1