From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29549 invoked from network); 8 Jul 2009 08:58:51 -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; 8 Jul 2009 08:58:51 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 97224 invoked from network); 8 Jul 2009 08:58:45 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 8 Jul 2009 08:58:45 -0000 Received: (qmail 12075 invoked by alias); 8 Jul 2009 08:58:39 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 27098 Received: (qmail 12048 invoked from network); 8 Jul 2009 08:58:38 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 8 Jul 2009 08:58:38 -0000 Received: from cluster-d.mailcontrol.com (cluster-d.mailcontrol.com [85.115.60.190]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 0641580307FA for ; Wed, 8 Jul 2009 10:58:35 +0200 (CEST) Received: from cameurexb01.EUROPE.ROOT.PRI ([193.128.72.68]) by rly01d.srv.mailcontrol.com (MailControl) with ESMTP id n688wUKS022622 for ; Wed, 8 Jul 2009 09:58:34 +0100 Received: from news01.csr.com ([10.99.50.25]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.3959); Wed, 8 Jul 2009 09:58:33 +0100 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.14.2/8.13.4) with ESMTP id n688wXa7030611 for ; Wed, 8 Jul 2009 09:58:33 +0100 Received: from csr.com (pws@localhost) by news01.csr.com (8.14.2/8.14.2/Submit) with ESMTP id n688wXfc030608 for ; Wed, 8 Jul 2009 09:58:33 +0100 Message-Id: <200907080858.n688wXfc030608@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk Subject: Re: non-interactive set -m In-reply-to: References: Comments: In-reply-to Eric Blake message dated "Tue, 07 Jul 2009 21:08:57 -0000." Date: Wed, 08 Jul 2009 09:58:33 +0100 From: Peter Stephenson X-OriginalArrivalTime: 08 Jul 2009 08:58:33.0299 (UTC) FILETIME=[458A6230:01C9FFAA] X-Scanned-By: MailControl A-09-20-00 (www.mailcontrol.com) on 10.68.0.111 X-Virus-Scanned: ClamAV 0.94.2/9542/Wed Jul 8 09:20:12 2009 on bifrost X-Virus-Status: Clean Eric Blake wrote: > As far as I can tell, POSIX requires 'set -m' to work even in non-interactive > > shells, if the shell implements the User Portability Utilities (UP) option. > POSIX is also explicit that 'set -b' shall default to disabled. Therefore, I > > claim that this demonstrates two bugs: > > $ zsh -c 'emulate sh; echo $-; set -m && set +m' > b > zsh:set:1: can't change option: -m > $ echo 1 The -b behaviour isn't a bug: use "emulate -R sh" to get all options, including ones that don't affect syntax, reset to the emulation defaults. However, making the shell start up in zsh mode and switching is increasing the complexity of what's going on; something like ARGV0=sh zsh -c 'echo $-' is easier and the output should be empty. (Alternatively, if you're not starting from zsh, use a symbolic link to zsh.) Part of my reason for suggesting that is the following. It's true you can't change the MONITOR option after the shell starts. It's probably fixable, but being able to switch back and forth might be complicated (though I haven't looked in detail). However, making MONITOR work at startup isn't so hard: the following simple patch stops it being tied to interactive mode. As this has no effect unless you request MONITOR, it won't cause problems elsewhere. This would mean that ARGV0=sh zsh -mc '...' will enable monitor mode at startup. Note that you do need a tty or pty of some sort (that's what SHTTY != -1 is testing), but that's probably obvious from the way job control works. What I don't know and haven't tested is whether MONITOR actually works in a non-interative shell. A simple test suggested it was basically OK. If someone can investigate whether there are any problems with the following patch I will see if they are easy to fix. Index: Src/init.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/init.c,v retrieving revision 1.101 diff -u -r1.101 init.c --- Src/init.c 1 Jul 2009 15:07:33 -0000 1.101 +++ Src/init.c 8 Jul 2009 08:49:21 -0000 @@ -486,7 +486,7 @@ * process group leader. */ mypid = (zlong)getpid(); - if (opts[MONITOR] && interact && (SHTTY != -1)) { + if (opts[MONITOR] && (SHTTY != -1)) { origpgrp = GETPGRP(); acquire_pgrp(); /* might also clear opts[MONITOR] */ } else -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070