1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-12-09 18:51:46 +01:00

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.
This commit is contained in:
Wayne Davison 2001-04-11 05:26:26 +00:00
parent ca3f1a3b79
commit e3e22f715c

View file

@ -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;
}