From 6a8aa2aa5a07c46a6b6d5c481a18a12e7ab6047a Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Tue, 1 Mar 2022 17:27:42 +0000 Subject: 49783: Consistently use old job table in parameter module --- Src/jobs.c | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) (limited to 'Src/jobs.c') diff --git a/Src/jobs.c b/Src/jobs.c index f0b337110..18e43f03c 100644 --- a/Src/jobs.c +++ b/Src/jobs.c @@ -98,10 +98,12 @@ mod_export int jobtabsize; mod_export int maxjob; /* If we have entered a subshell, the original shell's job table. */ -static struct job *oldjobtab; +/**/ +mod_export struct job *oldjobtab; /* The size of that. */ -static int oldmaxjob; +/**/ +mod_export int oldmaxjob; /* shell timings */ @@ -1894,6 +1896,26 @@ setcurjob(void) } } +/* Find the job table for reporting jobs */ + +/**/ +mod_export void +selectjobtab(Job *jtabp, int *jmaxp) +{ + if (oldjobtab) + { + /* In subshell --- use saved job table to report */ + *jtabp = oldjobtab; + *jmaxp = oldmaxjob; + } + else + { + /* Use main job table */ + *jtabp = jobtab; + *jmaxp = maxjob; + } +} + /* Convert a job specifier ("%%", "%1", "%foo", "%?bar?", etc.) * * to a job number. */ @@ -1904,13 +1926,7 @@ getjob(const char *s, const char *prog) int jobnum, returnval, mymaxjob; Job myjobtab; - if (oldjobtab) { - myjobtab = oldjobtab; - mymaxjob = oldmaxjob; - } else { - myjobtab= jobtab; - mymaxjob = maxjob; - } + selectjobtab(&myjobtab, &mymaxjob); /* if there is no %, treat as a name */ if (*s != '%') -- cgit 1.4.1