about summary refs log tree commit diff
path: root/Src/jobs.c
diff options
context:
space:
mode:
authorPeter Stephenson <p.stephenson@samsung.com>2022-03-01 17:27:42 +0000
committerPeter Stephenson <p.stephenson@samsung.com>2022-03-01 17:27:42 +0000
commit6a8aa2aa5a07c46a6b6d5c481a18a12e7ab6047a (patch)
tree4d0fe9bf0f92d7edd2ad200540d99e6cd6a90820 /Src/jobs.c
parent24474bd34a1c19d86ae2adee247f286e2e702815 (diff)
downloadzsh-6a8aa2aa5a07c46a6b6d5c481a18a12e7ab6047a.tar.gz
zsh-6a8aa2aa5a07c46a6b6d5c481a18a12e7ab6047a.tar.xz
zsh-6a8aa2aa5a07c46a6b6d5c481a18a12e7ab6047a.zip
49783: Consistently use old job table in parameter module
Diffstat (limited to 'Src/jobs.c')
-rw-r--r--Src/jobs.c34
1 files changed, 25 insertions, 9 deletions
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 != '%')