summaryrefslogtreecommitdiff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/exec.c8
-rw-r--r--Src/parse.c11
2 files changed, 14 insertions, 5 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 3c3fcfa3e..2b8e2167f 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -5157,23 +5157,25 @@ execfuncdef(Estate state, Eprog redir_prog)
{
Shfunc shf;
char *s = NULL;
- int signum, nprg, sbeg, nstrs, npats, len, plen, i, htok = 0, ret = 0;
+ int signum, nprg, sbeg, nstrs, npats, do_tracing, len, plen, i, htok = 0, ret = 0;
int anon_func = 0;
Wordcode beg = state->pc, end;
Eprog prog;
Patprog *pp;
LinkList names;
+ int tracing_flags;
end = beg + WC_FUNCDEF_SKIP(state->pc[-1]);
names = ecgetlist(state, *state->pc++, EC_DUPTOK, &htok);
sbeg = *state->pc++;
nstrs = *state->pc++;
npats = *state->pc++;
- (void) *state->pc++;
+ do_tracing = *state->pc++;
nprg = (end - state->pc);
plen = nprg * sizeof(wordcode);
len = plen + (npats * sizeof(Patprog)) + nstrs;
+ tracing_flags = do_tracing ? PM_TAGGED_LOCAL : 0;
if (htok && names) {
execsubst(names);
@@ -5223,7 +5225,7 @@ execfuncdef(Estate state, Eprog redir_prog)
shf = (Shfunc) zalloc(sizeof(*shf));
shf->funcdef = prog;
- shf->node.flags = 0;
+ shf->node.flags = tracing_flags;
/* No dircache here, not a directory */
shf->filename = ztrdup(scriptfilename);
shf->lineno =
diff --git a/Src/parse.c b/Src/parse.c
index 0111c25b6..0342ee1f8 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -173,7 +173,7 @@ struct heredocs *hdocs;
* - followed by offset to first string
* - followed by length of string table
* - followed by number of patterns for body
- * - followed by a placeholder
+ * - followed by an integer indicating tracing status
* - followed by codes for body
* - followed by strings for body
* - if number of names is 0, followed by:
@@ -1670,6 +1670,7 @@ par_funcdef(int *cmplx)
int oecused = ecused, num = 0, onp, p, c = 0;
int so, oecssub = ecssub;
zlong oldlineno = lineno;
+ int do_tracing = 0;
lineno = 0;
nocorrect = 1;
@@ -1679,6 +1680,12 @@ par_funcdef(int *cmplx)
p = ecadd(0);
ecadd(0); /* p + 1 */
+ if (tok == STRING && tokstr[0] == Dash &&
+ tokstr[1] == 'T' && !tokstr[2]) {
+ ++do_tracing;
+ zshlex();
+ }
+
while (tok == STRING) {
if ((*tokstr == Inbrace || *tokstr == '{') &&
!tokstr[1]) {
@@ -1732,7 +1739,7 @@ par_funcdef(int *cmplx)
ecbuf[p + num + 2] = so - oecssub;
ecbuf[p + num + 3] = ecsoffs - so; /* "length of string table" */
ecbuf[p + num + 4] = ecnpats; /* "number of patterns for body" */
- ecbuf[p + num + 5] = 0;
+ ecbuf[p + num + 5] = do_tracing;
ecbuf[p + 1] = num; /* "number of names" */
ecnpats = onp;