Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: jobs -d &>/dev/null still produces output?



On a machine that I can't use the latest cvs on:  Is there any sort of
file descriptor magic that I can use to work around this and get it to
send that to somewhere other than the terminal, or am I just stuck
with its current behavior?

On 11/3/06, Peter Stephenson <pws@xxxxxxx> wrote:
"Matt Wozniski" <godlygeek@xxxxxxxxx> wrote:
> I'm a bit confused by something zsh is doing.
>
> Test case:
>
> sleep 1000 &
> jobs -d &>/dev/null
>
> Why does this still produce output?

The line you're seeing is the same line that would usually be produced
when, for example, you run "fg" and the process that's brought to the
foreground is running in a different directory.  Since this is purely an
interactive informational message it's directed straight to the terminal.

It's less useful when this happens in the "jobs" command, however, since in
that case the above doesn't apply and you'd expect the output to appear in
one place.  I think it would be more consistent to do what we already
do with other output and send it to stdout rather than the terminal if
it's run from "jobs".

Index: Src/jobs.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v
retrieving revision 1.48
diff -u -r1.48 jobs.c
--- Src/jobs.c  30 Oct 2006 10:37:18 -0000      1.48
+++ Src/jobs.c  3 Nov 2006 19:41:31 -0000
@@ -954,10 +954,10 @@

     if ((lng & 4) || (interact && job == thisjob &&
                      jn->pwd && strcmp(jn->pwd, pwd))) {
-       fprintf(shout, "(pwd %s: ", (lng & 4) ? "" : "now");
-       fprintdir(((lng & 4) && jn->pwd) ? jn->pwd : pwd, shout);
-       fprintf(shout, ")\n");
-       fflush(shout);
+       fprintf(fout, "(pwd %s: ", (lng & 4) ? "" : "now");
+       fprintdir(((lng & 4) && jn->pwd) ? jn->pwd : pwd, fout);
+       fprintf(fout, ")\n");
+       fflush(fout);
     }
 /* delete job if done */

@@ -1827,11 +1827,12 @@
                printjob(jobtab + job, (stopped) ? -1 : lng, 1);
            if (func != BIN_BG) {               /* fg or wait */
                if (jobtab[job].pwd && strcmp(jobtab[job].pwd, pwd)) {
-                   fprintf(shout, "(pwd : ");
-                   fprintdir(jobtab[job].pwd, shout);
-                   fprintf(shout, ")\n");
+                   FILE *fout = (func == BIN_JOBS) ? stdout : shout;
+                   fprintf(fout, "(pwd : ");
+                   fprintdir(jobtab[job].pwd, fout);
+                   fprintf(fout, ")\n");
+                   fflush(fout);
                }
-               fflush(shout);
                if (func != BIN_WAIT) {         /* fg */
                    thisjob = job;
                    if ((jobtab[job].stat & STAT_SUPERJOB) &&


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php




Messages sorted by: Reverse Date, Date, Thread, Author