zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: compinit in sourced file breaks bg command!?!
Date: Tue, 27 Mar 2007 11:42:06 +0100	[thread overview]
Message-ID: <20070327114206.c7e3494d.pws@csr.com> (raw)
In-Reply-To: <20070327093306.GA4885@sc.homeunix.net>

Stephane Chazelas <Stephane_Chazelas@yahoo.fr> wrote:
> I've been experiencing an annoting behavior of bg recently.
> 
> $ cmd
> <CTRL-Z>
> $ bg
> 
> and  cmd is not made the "current job".

Thanks for spotting this, I would probably not have noticed...

zsh keeps a record of both the current and previous jobs, marked +
and - in job lists.  The logic that handles them is a little obscure,
but apparently it usually works so I haven't looked in any detail.

In this case there was another job in the job table, and that was being
made the current job.  Apparently this was coming from the compinit stuff,
although the details of how aren't important:  the point was that this
job was being marked as "done", but not being deleted from the table.
It turns out the job was also marked as not to be displayed to the user
("noprint"), and it seems that in that case we return from the job-printing
function without bothering to delete the job.

Fixing that logical error seems to make the problem go away.  Let me know
if it doesn't.

Index: Src/jobs.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/jobs.c,v
retrieving revision 1.54
diff -u -r1.54 jobs.c
--- Src/jobs.c	30 Jan 2007 19:03:46 -0000	1.54
+++ Src/jobs.c	27 Mar 2007 10:36:29 -0000
@@ -806,7 +806,10 @@
  * synch = 2 means called synchronously from jobs
  *
  * Returns 1 if some output was done.
-*/
+ *
+ * The function also deletes the job if it was done, even it
+ * is not printed.
+ */
 
 /**/
 int
@@ -818,8 +821,18 @@
     int doneprint = 0;
     FILE *fout = (synch == 2) ? stdout : shout;
 
-    if (jn->stat & STAT_NOPRINT)
+    if (jn->stat & STAT_NOPRINT) {
+	if (jn->stat & STAT_DONE) {
+	    deletejob(jn);
+	if (job == curjob) {
+	    curjob = prevjob;
+	    prevjob = job;
+	}
+	if (job == prevjob)
+	    setprevjob();
+	}
 	return 0;
+    }
 
     /*
      * Wow, what a hack.  Did I really write this? --- pws

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


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

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview


  reply	other threads:[~2007-03-27 10:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-27  9:33 Stephane Chazelas
2007-03-27 10:42 ` Peter Stephenson [this message]
2007-03-27 15:08   ` Bart Schaefer
2007-03-27 16:45   ` Stephane Chazelas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070327114206.c7e3494d.pws@csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).