about summary refs log tree commit diff
path: root/Src/jobs.c
diff options
context:
space:
mode:
Diffstat (limited to 'Src/jobs.c')
-rw-r--r--Src/jobs.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Src/jobs.c b/Src/jobs.c
index be44158c6..0188989df 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -1488,14 +1488,14 @@ bin_fg(char *name, char **argv, Options ops, int func)
 	    int curmaxjob, ignorejob;
 	    if (unset(MONITOR) && oldmaxjob) {
 		jobptr = oldjobtab;
-		curmaxjob = oldmaxjob;
+		curmaxjob = oldmaxjob ? oldmaxjob - 1 : 0;
 		ignorejob = 0;
 	    } else {
 		jobptr = jobtab;
 		curmaxjob = maxjob;
 		ignorejob = thisjob;
 	    }
-	    for (job = 0; job != curmaxjob; job++, jobptr++)
+	    for (job = 0; job <= curmaxjob; job++, jobptr++)
 		if (job != ignorejob && jobptr->stat) {
 		    if ((!OPT_ISSET(ops,'r') && !OPT_ISSET(ops,'s')) ||
 			(OPT_ISSET(ops,'r') && OPT_ISSET(ops,'s')) ||