From 9fc3e9a8dbfd2bbce2fd825a104414994539cd4d Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Fri, 14 Jan 2000 15:55:31 +0000 Subject: zsh-workers/9318 --- Src/exec.c | 10 +++++++--- Src/init.c | 2 +- Src/zsh.h | 13 +++++++------ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Src/exec.c b/Src/exec.c index af5a02f9c..0c87f4500 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -1053,7 +1053,7 @@ execpline2(Pline pline, int how, int input, int output, int last1) lineno = pline->left->lineno; if (pline_level == 1) { - if (!sfcontext) + if ((how & Z_ASYNC) || (!sfcontext && !sourcelevel)) strcpy(list_pipe_text, getjobtext((void *) pline->left)); else list_pipe_text[0] = '\0'; @@ -1639,7 +1639,8 @@ execcmd(Cmd cmd, int input, int output, int how, int last1) } /* Get the text associated with this command. */ - if (!sfcontext && (jobbing || (how & Z_TIMED))) + if ((how & Z_ASYNC) || + (!sfcontext && !sourcelevel && (jobbing || (how & Z_TIMED)))) text = getjobtext((void *) cmd); else text = NULL; @@ -2854,7 +2855,7 @@ execshfunc(Cmd cmd, Shfunc shf, LinkList args) { LinkList last_file_list = NULL; unsigned char *ocs; - int ocsp; + int ocsp, osfc; if (errflag) return; @@ -2882,7 +2883,10 @@ execshfunc(Cmd cmd, Shfunc shf, LinkList args) ocsp = cmdsp; cmdstack = (unsigned char *) zalloc(CMDSTACKSZ); cmdsp = 0; + if ((osfc = sfcontext) == SFC_NONE) + sfcontext = SFC_DIRECT; doshfunc(shf->nam, shf->funcdef, args, shf->flags, 0); + sfcontext = osfc; free(cmdstack); cmdstack = ocs; cmdsp = ocsp; diff --git a/Src/init.c b/Src/init.c index 5c2a68728..11d9ab65c 100644 --- a/Src/init.c +++ b/Src/init.c @@ -708,7 +708,7 @@ setupvals(void) breaks = loops = 0; lastmailcheck = time(NULL); locallevel = sourcelevel = 0; - sfcontext = SFC_DIRECT; + sfcontext = SFC_NONE; trapreturn = 0; noerrexit = -1; nohistsave = 1; diff --git a/Src/zsh.h b/Src/zsh.h index 5c40cb945..88842e7d4 100644 --- a/Src/zsh.h +++ b/Src/zsh.h @@ -850,12 +850,13 @@ struct shfunc { /* Shell function context types. */ -#define SFC_DIRECT 0 /* called directly from the user */ -#define SFC_SIGNAL 1 /* signal handler */ -#define SFC_HOOK 2 /* one of the special functions */ -#define SFC_WIDGET 3 /* user defined widget */ -#define SFC_COMPLETE 4 /* called from completion code */ -#define SFC_CWIDGET 5 /* new style completion widget */ +#define SFC_NONE 0 /* no function running */ +#define SFC_DIRECT 1 /* called directly from the user */ +#define SFC_SIGNAL 2 /* signal handler */ +#define SFC_HOOK 3 /* one of the special functions */ +#define SFC_WIDGET 4 /* user defined widget */ +#define SFC_COMPLETE 5 /* called from completion code */ +#define SFC_CWIDGET 6 /* new style completion widget */ /* node in list of function call wrappers */ -- cgit 1.4.1