From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18753 invoked from network); 8 Jul 2009 13:26:41 -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=BAYES_00,UNPARSEABLE_RELAY 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 13:26:41 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 71253 invoked from network); 8 Jul 2009 13:26:32 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 8 Jul 2009 13:26:32 -0000 Received: (qmail 11424 invoked by alias); 8 Jul 2009 13:26:21 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 27099 Received: (qmail 11405 invoked from network); 8 Jul 2009 13:26:20 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 8 Jul 2009 13:26:20 -0000 Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 594A180307FB for ; Wed, 8 Jul 2009 15:26:13 +0200 (CEST) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1MOXA4-0004pV-RS for zsh-workers@sunsite.dk; Wed, 08 Jul 2009 13:26:13 +0000 Received: from c-24-10-247-15.hsd1.ut.comcast.net ([c-24-10-247-15.hsd1.ut.comcast.net]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 08 Jul 2009 13:26:12 +0000 Received: from ebb9 by c-24-10-247-15.hsd1.ut.comcast.net with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 08 Jul 2009 13:26:12 +0000 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-workers@sunsite.dk From: Eric Blake Subject: Re: non-interactive set -m Date: Wed, 8 Jul 2009 13:26:02 +0000 (UTC) Message-ID: References: <200907080858.n688wXfc030608@news01.csr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: main.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 24.10.247.15 (Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.16) Gecko/20080702 Firefox/2.0.0.16 Mnenhy/0.7.5.666) Sender: news X-Virus-Scanned: ClamAV 0.94.2/9546/Wed Jul 8 13:39:15 2009 on bifrost X-Virus-Status: Clean Peter Stephenson csr.com> writes: > 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). POSIX requires that 'set -m'/'set -o monitor' be switchable on the fly, without regards to whether the shell is interactive. And your claim that MONITOR cannot be changed on the fly is false: zsh already handles this for interactive shells, with knock-on effects that fg and bg change behavior depending on the current state of MONITOR (also as specified by POSIX). $ ARGV0=sh zsh -ci 'echo $-; set +m; sleep 1& fg; echo $-; set -m; echo $-' 569XZim zsh:fg:1: no job control in this shell. 569XZi 569XZim > 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. Unfortunately, for autoconf's purposes, that is not possible without contortions of re-starting a script if it is detected that zsh is running the script but not in sh mode. Autoconf does not have control over how the user started a script, but wants the shell to be in POSIX mode after the point that the script is already started, as part of sanitizing the environment to be portable across as many shells as possible, so autoconf is forced to use 'emulate sh' (although we may switch it to use 'emulate -R sh', based on your advice). > 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. You are correct that you can't change interactive mode on the fly - whether $- prints i is fixed from the moment the shell starts up. You are also correct that the initial state of MONITOR depends on whether the shell is interactive, and that whether a shell is interactive depends, in part, on whether there is a tty: POSIX requires that interactive shells start with 'set -m' and non-interactive shells start with 'set +m' unless specified differently by other command line options, so at startup, $- will usually contain either both or neither of 'im'. But while the presence of a tty is a factor for determining whether the shell is interactive, it is NOT a factor in determining whether job control works. Job control works just fine without a tty, as proved by bash and ksh. Meanwhile, the presence of a tty is not the ONLY way to get an interactive shell; POSIX requires that even without a tty, a shell started with an explicit -i must be interactive (although in this condition, the shell need not print prompts). According to POSIX, job control does two things - it changes messages printed before a prompt (related to interactivity and the presence of a tty), and it makes it possible to spawn asynchronous processes in separate process groups for independent tracking. It is the latter part (separate process groups) that autoconf wants to use to enable parallel testsuites, and which is unrelated to whether there is a tty. And in a non-interactive shell, the former part (printing a message before prompts) does not matter, since non-interactive shells never print prompts in the first place. Basically, zsh cannot be used for parallel autoconf tests unless you fix the bug of allowing job control support to be changed on the fly for non-interactive shells. -- Eric Blake