From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5848 invoked from network); 10 Jul 2009 11:05:18 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.5 Received: from new-brage.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.254.104) by ns1.primenet.com.au with SMTP; 10 Jul 2009 11:05:18 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 38984 invoked from network); 10 Jul 2009 11:05:08 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 10 Jul 2009 11:05:08 -0000 Received: (qmail 11217 invoked by alias); 10 Jul 2009 11:04:56 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 27122 Received: (qmail 11194 invoked from network); 10 Jul 2009 11:04:55 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 10 Jul 2009 11:04:55 -0000 Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [85.115.60.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 963E780307FA for ; Fri, 10 Jul 2009 13:04:38 +0200 (CEST) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly04d.srv.mailcontrol.com (MailControl) with ESMTP id n6AB4ZBB024170 for ; Fri, 10 Jul 2009 12:04:36 +0100 Received: from news01 ([10.99.50.25]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Fri, 10 Jul 2009 11:53:42 +0100 Date: Fri, 10 Jul 2009 11:53:42 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: non-interactive set -m Message-ID: <20090710115342.025587a8@news01> In-Reply-To: <20090710095813.4cc774b0@news01> References: <200907080858.n688wXfc030608@news01.csr.com> <200907081349.n68DneSv001850@news01.csr.com> <20090709212345.05cc2213@pws-pc> <20090710095813.4cc774b0@news01> Organization: CSR X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.8; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 10 Jul 2009 10:53:42.0945 (UTC) FILETIME=[B0D63110:01CA014C] X-Scanned-By: MailControl A-09-20-00 (www.mailcontrol.com) on 10.68.0.114 X-Virus-Scanned: ClamAV 0.94.2/9551/Thu Jul 9 15:22:08 2009 on bifrost X-Virus-Status: Clean On Fri, 10 Jul 2009 09:58:13 +0100 Peter Stephenson wrote: > On Thu, 9 Jul 2009 21:40:19 +0000 (UTC) > > Also, POSIX states that fg output should be the name of the command that was > > brought into the foreground, and not the 'jobs' output describing that > > command. > > Haven't looked at this, but as an annoying fiddly difference it probably > needs to be an option. Straightforward if an annoying increase in mess. I've partly gone back on the previous going back on the previous patch that printed a message if non-interactive but with job-control---I think we need to do it if synchronous, so we get the output from "fg" and "bg". Index: Doc/Zsh/options.yo =================================================================== RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v retrieving revision 1.82 diff -u -r1.82 options.yo --- Doc/Zsh/options.yo 17 May 2009 18:23:10 -0000 1.82 +++ Doc/Zsh/options.yo 10 Jul 2009 10:48:57 -0000 @@ -1274,6 +1274,17 @@ Report the status of background jobs immediately, rather than waiting until just before printing a prompt. ) +pindex(POSIX_JOBS) +pindex(POSIXJOBS) +pindex(NO_POSIX_JOBS) +pindex(NOPOSIXJOBS) +cindex(bg, output in POSIX format) +cindex(fg, output in POSIX format) +item(tt(POSIX_JOBS) )( +When putting jobs in the background or foreground with tt(bg) or tt(fg), +just print the text of the job as required by POSIX, +rather than the full information that would be output by tt(jobs). +) enditem() subsect(Prompting) Index: Src/jobs.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v retrieving revision 1.68 diff -u -r1.68 jobs.c --- Src/jobs.c 10 Jul 2009 09:11:12 -0000 1.68 +++ Src/jobs.c 10 Jul 2009 10:48:57 -0000 @@ -813,6 +813,7 @@ * synch = 0 means asynchronous * synch = 1 means synchronous * synch = 2 means called synchronously from jobs + * synch = 3 means called synchronously from bg or fg * * Returns 1 if some output was done. * @@ -884,12 +885,18 @@ } } -/* print if necessary: ignore option state on explicit call to `jobs'. */ - + /* + * - Always print if called from jobs + * - Otherwise, require MONITOR option ("jobbing") and some + * change of state + * - also either the shell is interactive or this is synchronous. + */ if (synch == 2 || - (interact && jobbing && + ((interact || synch) && jobbing && ((jn->stat & STAT_STOPPED) || sflag || job != thisjob))) { int len2, fline = 1; + /* POSIX requires just the job text for bg and fg */ + int plainfmt = (synch == 3) && isset(POSIXJOBS); /* use special format for current job, except in `jobs' */ int thisfmt = job == thisjob && synch != 2; Process qn; @@ -908,54 +915,60 @@ for (qn = pn->next; qn; qn = qn->next) { if (qn->status != pn->status) break; - if ((int)strlen(qn->text) + len2 + ((qn->next) ? 3 : 0) > lineleng) + if ((int)strlen(qn->text) + len2 + ((qn->next) ? 3 : 0) + > lineleng) break; len2 += strlen(qn->text) + 2; } doneprint = 1; - if (!thisfmt || lng) { - if (fline) - fprintf(fout, "[%ld] %c ", - (long)job, - (job == curjob) ? '+' - : (job == prevjob) ? '-' : ' '); - else - fprintf(fout, (job > 9) ? " " : " "); - } else - fprintf(fout, "zsh: "); - if (lng & 1) - fprintf(fout, "%ld ", (long) pn->pid); - else if (lng & 2) { - pid_t x = jn->gleader; - - fprintf(fout, "%ld ", (long) x); - do + if (!plainfmt) { + if (!thisfmt || lng) { + if (fline) + fprintf(fout, "[%ld] %c ", + (long)job, + (job == curjob) ? '+' + : (job == prevjob) ? '-' : ' '); + else + fprintf(fout, (job > 9) ? " " : " "); + } else + fprintf(fout, "zsh: "); + if (lng & 1) + fprintf(fout, "%ld ", (long) pn->pid); + else if (lng & 2) { + pid_t x = jn->gleader; + + fprintf(fout, "%ld ", (long) x); + do + skip++; + while ((x /= 10)); skip++; - while ((x /= 10)); - skip++; - lng &= ~3; - } else - fprintf(fout, "%*s", skip, ""); - if (pn->status == SP_RUNNING) { - if (!conted) - fprintf(fout, "running%*s", len - 7 + 2, ""); + lng &= ~3; + } else + fprintf(fout, "%*s", skip, ""); + if (pn->status == SP_RUNNING) { + if (!conted) + fprintf(fout, "running%*s", len - 7 + 2, ""); + else + fprintf(fout, "continued%*s", len - 9 + 2, ""); + } + else if (WIFEXITED(pn->status)) { + if (WEXITSTATUS(pn->status)) + fprintf(fout, "exit %-4d%*s", WEXITSTATUS(pn->status), + len - 9 + 2, ""); + else + fprintf(fout, "done%*s", len - 4 + 2, ""); + } else if (WIFSTOPPED(pn->status)) + fprintf(fout, "%-*s", len + 2, + sigmsg(WSTOPSIG(pn->status))); + else if (WCOREDUMP(pn->status)) + fprintf(fout, "%s (core dumped)%*s", + sigmsg(WTERMSIG(pn->status)), + (int)(len - 14 + 2 - + strlen(sigmsg(WTERMSIG(pn->status)))), ""); else - fprintf(fout, "continued%*s", len - 9 + 2, ""); + fprintf(fout, "%-*s", len + 2, + sigmsg(WTERMSIG(pn->status))); } - else if (WIFEXITED(pn->status)) { - if (WEXITSTATUS(pn->status)) - fprintf(fout, "exit %-4d%*s", WEXITSTATUS(pn->status), - len - 9 + 2, ""); - else - fprintf(fout, "done%*s", len - 4 + 2, ""); - } else if (WIFSTOPPED(pn->status)) - fprintf(fout, "%-*s", len + 2, sigmsg(WSTOPSIG(pn->status))); - else if (WCOREDUMP(pn->status)) - fprintf(fout, "%s (core dumped)%*s", - sigmsg(WTERMSIG(pn->status)), - (int)(len - 14 + 2 - strlen(sigmsg(WTERMSIG(pn->status)))), ""); - else - fprintf(fout, "%-*s", len + 2, sigmsg(WTERMSIG(pn->status))); for (; pn != qn; pn = pn->next) { char *txt = dupstring(pn->text); int txtlen; @@ -1904,7 +1918,7 @@ } if (func != BIN_WAIT) /* for bg and fg -- show the job we are operating on */ - printjob(jobtab + job, (stopped) ? -1 : lng, 1); + printjob(jobtab + job, (stopped) ? -1 : lng, 3); if (func != BIN_BG) { /* fg or wait */ if (jobtab[job].pwd && strcmp(jobtab[job].pwd, pwd)) { FILE *fout = (func == BIN_JOBS || !shout) ? stdout : shout; Index: Src/options.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/options.c,v retrieving revision 1.49 diff -u -r1.49 options.c --- Src/options.c 8 Jul 2009 17:07:14 -0000 1.49 +++ Src/options.c 10 Jul 2009 10:48:57 -0000 @@ -201,6 +201,7 @@ {{NULL, "posixaliases", OPT_EMULATE|OPT_BOURNE}, POSIXALIASES}, {{NULL, "posixbuiltins", OPT_EMULATE|OPT_BOURNE}, POSIXBUILTINS}, {{NULL, "posixidentifiers", OPT_EMULATE|OPT_BOURNE}, POSIXIDENTIFIERS}, +{{NULL, "posixjobs", OPT_EMULATE|OPT_BOURNE}, POSIXJOBS}, {{NULL, "printeightbit", 0}, PRINTEIGHTBIT}, {{NULL, "printexitvalue", 0}, PRINTEXITVALUE}, {{NULL, "privileged", OPT_SPECIAL}, PRIVILEGED}, Index: Src/zsh.h =================================================================== RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v retrieving revision 1.158 diff -u -r1.158 zsh.h --- Src/zsh.h 2 Jul 2009 13:48:36 -0000 1.158 +++ Src/zsh.h 10 Jul 2009 10:48:57 -0000 @@ -1955,6 +1956,7 @@ POSIXALIASES, POSIXBUILTINS, POSIXIDENTIFIERS, + POSIXJOBS, PRINTEIGHTBIT, PRINTEXITVALUE, PRIVILEGED, -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070