about summary refs log tree commit diff
path: root/Src/jobs.c
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2009-07-09 20:33:56 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2009-07-09 20:33:56 +0000
commit5df700fb5b367ed6a5bec0fcac6723bbc3bf24d7 (patch)
tree0c1436d462c82930fbab5125f9d8f847678dfe01 /Src/jobs.c
parentce4137c858d2e24cdcd341d070345b8296bd576f (diff)
downloadzsh-5df700fb5b367ed6a5bec0fcac6723bbc3bf24d7.tar.gz
zsh-5df700fb5b367ed6a5bec0fcac6723bbc3bf24d7.tar.xz
zsh-5df700fb5b367ed6a5bec0fcac6723bbc3bf24d7.zip
27112: allow jobbing output if not interactive
Diffstat (limited to 'Src/jobs.c')
-rw-r--r--Src/jobs.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/Src/jobs.c b/Src/jobs.c
index df1787b79..7f4aed144 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -828,7 +828,7 @@ printjob(Job jn, int lng, int synch)
     int job, len = 9, sig, sflag = 0, llen;
     int conted = 0, lineleng = columns, skip = 0, doputnl = 0;
     int doneprint = 0;
-    FILE *fout = (synch == 2) ? stdout : shout;
+    FILE *fout = (synch == 2) ? stdout : shout ? shout : stderr;
 
     if (oldjobtab != NULL)
 	job = jn - oldjobtab;
@@ -887,7 +887,7 @@ printjob(Job jn, int lng, int synch)
 /* print if necessary: ignore option state on explicit call to `jobs'. */
 
     if (synch == 2 || 
-	(interact && jobbing &&
+	(jobbing &&
 	 ((jn->stat & STAT_STOPPED) || sflag || job != thisjob))) {
 	int len2, fline = 1;
 	/* use special format for current job, except in `jobs' */
@@ -1379,12 +1379,13 @@ spawnjob(void)
 	    setprevjob();
 	} else if (prevjob == -1 || !(jobtab[prevjob].stat & STAT_STOPPED))
 	    prevjob = thisjob;
-	if (interact && jobbing && jobtab[thisjob].procs) {
-	    fprintf(shout, "[%d]", thisjob);
+	if (jobbing && jobtab[thisjob].procs) {
+	    FILE *fout = shout ? shout : stderr;
+	    fprintf(fout, "[%d]", thisjob);
 	    for (pn = jobtab[thisjob].procs; pn; pn = pn->next)
-		fprintf(shout, " %ld", (long) pn->pid);
-	    fprintf(shout, "\n");
-	    fflush(shout);
+		fprintf(fout, " %ld", (long) pn->pid);
+	    fprintf(fout, "\n");
+	    fflush(fout);
 	}
     }
     if (!hasprocs(thisjob))
@@ -1907,7 +1908,8 @@ bin_fg(char *name, char **argv, Options ops, int func)
 		printjob(jobtab + job, (stopped) ? -1 : lng, 1);
 	    if (func != BIN_BG) {		/* fg or wait */
 		if (jobtab[job].pwd && strcmp(jobtab[job].pwd, pwd)) {
-		    FILE *fout = (func == BIN_JOBS) ? stdout : shout;
+		    FILE *fout = (func == BIN_JOBS) ? stdout : shout ?
+			shout : stderr;
 		    fprintf(fout, "(pwd : ");
 		    fprintdir(jobtab[job].pwd, fout);
 		    fprintf(fout, ")\n");