From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14366 invoked from network); 9 Jul 2009 19:36:54 -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.6 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; 9 Jul 2009 19:36:54 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 67800 invoked from network); 9 Jul 2009 19:36:45 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 9 Jul 2009 19:36:45 -0000 Received: (qmail 11767 invoked by alias); 9 Jul 2009 19:36:33 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 27110 Received: (qmail 11753 invoked from network); 9 Jul 2009 19:36:32 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 9 Jul 2009 19:36:32 -0000 Received: from mtaout03-winn.ispmail.ntl.com (mtaout03-winn.ispmail.ntl.com [81.103.221.49]) by bifrost.dotsrc.org (Postfix) with ESMTP id 03AE180307FB for ; Thu, 9 Jul 2009 21:36:18 +0200 (CEST) Received: from aamtaout03-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout03-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20090709193618.CYNW5579.mtaout03-winn.ispmail.ntl.com@aamtaout03-winn.ispmail.ntl.com> for ; Thu, 9 Jul 2009 20:36:18 +0100 Received: from pws-pc ([81.107.42.185]) by aamtaout03-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20090709193618.DDBJ2093.aamtaout03-winn.ispmail.ntl.com@pws-pc> for ; Thu, 9 Jul 2009 20:36:18 +0100 Date: Thu, 9 Jul 2009 20:36:13 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: non-interactive set -m Message-ID: <20090709203613.437ae162@pws-pc> In-Reply-To: References: <200907080858.n688wXfc030608@news01.csr.com> <200907081349.n68DneSv001850@news01.csr.com> X-Mailer: Claws Mail 3.7.1 (GTK+ 2.16.2; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Cloudmark-Analysis: v=1.0 c=1 a=9vXuR5GGAAAA:8 a=NLZqzBF-AAAA:8 a=60xX2lZzadA-9XC0zgUA:9 a=H-TRkodCAmQg1oGTGDcA:7 a=3qMZ40grdSwko-hRpfJCy-xRMM4A:4 a=eDFNAWYWrCwA:10 a=_dQi-Dcv4p4A:10 X-Virus-Scanned: ClamAV 0.94.2/9551/Thu Jul 9 15:22:08 2009 on bifrost X-Virus-Status: Clean On Thu, 9 Jul 2009 18:13:15 +0000 (UTC) Eric Blake wrote: > As-is, your 2-hunk patch accidentally sets monitor mode by default for > non-interactive shells: > > $ Src/zsh -c 'echo $-' > 569Xm This is tricky: there's the knock-on effect from INTERACTIVE, and the possibility it might be set or unset. I think the following does it. Index: Src/init.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/init.c,v retrieving revision 1.102 diff -u -r1.102 init.c --- Src/init.c 8 Jul 2009 17:07:13 -0000 1.102 +++ Src/init.c 9 Jul 2009 19:33:44 -0000 @@ -233,6 +233,11 @@ * be changed. At the end of the function, a value of 2 gets * * changed to 1. */ opts[INTERACTIVE] = isatty(0) ? 2 : 0; + /* + * MONITOR is similar: we initialise it to 2, and if it's + * still 2 at the end, we set it to the value of INTERACTIVE. + */ + opts[MONITOR] = 2; /* may be unset in init_io() */ opts[SHINSTDIN] = 0; opts[SINGLECOMMAND] = 0; @@ -343,6 +348,8 @@ if(isset(SINGLECOMMAND)) opts[INTERACTIVE] &= 1; opts[INTERACTIVE] = !!opts[INTERACTIVE]; + if (opts[MONITOR] == 2) + opts[MONITOR] = opts[INTERACTIVE]; pparams = x = (char **) zshcalloc((countlinknodes(paramlist) + 1) * sizeof(char *)); while ((*x++ = (char *)getlinknode(paramlist))); @@ -1395,7 +1402,6 @@ createoptiontable(); emulate(zsh_name, 1); /* initialises most options */ opts[LOGINSHELL] = (**argv == '-'); - opts[MONITOR] = 1; /* may be unset in init_io() */ opts[PRIVILEGED] = (getuid() != geteuid() || getgid() != getegid()); opts[USEZLE] = 1; /* may be unset in init_io() */ parseargs(argv); /* sets INTERACTIVE, SHINSTDIN and SINGLECOMMAND */ -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/