From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13545 invoked from network); 28 Jun 2000 10:21:20 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 28 Jun 2000 10:21:19 -0000 Received: (qmail 138 invoked by alias); 28 Jun 2000 10:21:08 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 12106 Received: (qmail 130 invoked from network); 28 Jun 2000 10:21:06 -0000 Date: Wed, 28 Jun 2000 11:20:38 +0100 From: Peter Stephenson Subject: Re: jobs command in precmd In-reply-to: "Your message of Wed, 28 Jun 2000 11:36:11 +0200." <20000628113611.A20108@rambo.its.tudelft.nl> To: Rob Egelink , zsh-workers@sunsite.auc.dk (Zsh hackers list) Message-id: <0FWV001LZ0QDKS@la-la.cambridgesiliconradio.com> Content-transfer-encoding: 7BIT > Hello *, > > When I put the 'jobs' builtin command in my precmd function, zsh > exits immediately without giving me a warning that I still have > background jobs. > > I found out that zsh exits without a warning if the previous command > was the jobs command. > > But in my precmd function there are many commands after the jobs > command. The shell has a flag (which happens to be called stopmsg) to tell it that you've just looked at your jobs, and hence don't need to be warned again. The main use of this is that you need to be able to ignore the `you have XXX jobs' messages, otherwise you couldn't leave the shell at all. However, it's assumed that the `jobs' command also tells you all you need to know, so you can exit straight after. (You probably know all this.) The real difficulty is that the stopmsg is only reset when the shell gets back to the main command loop, i.e. after executing some block of commands on a single line. Arguably this is correct as far as it goes, since it doesn't matter how you see the message from `jobs' --- for example, you might have buried it inside your own shell function. But the case of precmd is a bit special, since effectively it all happens without your knowing. Maybe simply saving and restoring stopmsg when executing precmd would be enough. I don't have time to go into the details right now, however.