From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28720 invoked from network); 31 Jan 2009 21:10:29 -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 news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 31 Jan 2009 21:10:29 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 54584 invoked from network); 31 Jan 2009 21:10:25 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 31 Jan 2009 21:10:25 -0000 Received: (qmail 11269 invoked by alias); 31 Jan 2009 21:10:17 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26501 Received: (qmail 11254 invoked from network); 31 Jan 2009 21:10:16 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 31 Jan 2009 21:10:16 -0000 Received: from mtaout02-winn.ispmail.ntl.com (mtaout02-winn.ispmail.ntl.com [81.103.221.48]) by bifrost.dotsrc.org (Postfix) with ESMTP id EAB1D80271F0 for ; Sat, 31 Jan 2009 22:10:12 +0100 (CET) Received: from aamtaout01-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout02-winn.ispmail.ntl.com (InterMail vM.7.08.04.00 201-2186-134-20080326) with ESMTP id <20090131211012.ZDOB4080.mtaout02-winn.ispmail.ntl.com@aamtaout01-winn.ispmail.ntl.com> for ; Sat, 31 Jan 2009 21:10:12 +0000 Received: from pws-pc.ntlworld.com ([81.107.42.185]) by aamtaout01-winn.ispmail.ntl.com (InterMail vG.2.02.00.01 201-2161-120-102-20060912) with ESMTP id <20090131211012.DZUB19264.aamtaout01-winn.ispmail.ntl.com@pws-pc.ntlworld.com> for ; Sat, 31 Jan 2009 21:10:12 +0000 Received: from pws-pc (pws-pc [127.0.0.1]) by pws-pc.ntlworld.com (8.14.3/8.14.2) with ESMTP id n0VLA2bR006281 for ; Sat, 31 Jan 2009 21:10:02 GMT Message-Id: <200901312110.n0VLA2bR006281@pws-pc.ntlworld.com> From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: sourcing a sh file in zsh In-Reply-To: Message from Bart Schaefer of "Sat, 31 Jan 2009 12:40:43 PST." <090131124043.ZM7791@torch.brasslantern.com> Date: Sat, 31 Jan 2009 21:10:02 +0000 X-Cloudmark-Analysis: v=1.0 c=1 a=NLZqzBF-AAAA:8 a=FqQY6uwO35-YExW1PfUA:9 a=Yn0OgiY_QsDub3KaIJUkbzRdERAA:4 a=fUzIcyR-ki4A:10 X-Virus-Scanned: ClamAV 0.92.1/8931/Sat Jan 31 19:25:59 2009 on bifrost X-Virus-Status: Clean Bart Schaefer wrote: > We face a similar problem with the "sticky" emulation idea. Let's > suppose for purposes of illustration that "emulate -S" activates it. > > emulate -S sh -c 'debug() { set -vx }' > > (Imagine the debug function is buried in, and used by, some lengthy > piece of /bin/sh code that's being loaded.) What happens when the > debug function is executed? An implicit LOCAL_OPTIONS breaks the > intended behavior. Although I see you can argue different ways, my view of this was that this was "just tough". An "emulate" of this kind specifically sets and restores options. If you want option propagation, you shouldn't mix emulations. What would be the intention of the code above, anyway? I think the answer is it's for debugging in sh emulation. But then it belongs with the code you're debugging, doesn't it? emulate -S sh -c 'debug() { set -vx } ... sh code which calls debug ... ' Now in *this* case, I think it's clear that the option should propagate. But I think that's OK... there's no "emulate" firewall between the execution of debug and the code around. To get this right (if that is right), we do need to be careful about how we handle sticky emulation in functions: if we're already in the sticky emulation environment, as here, we don't want to set and restore options around execution of functions defined in the same emulation mode. That would be regardless of which chunks of code they were defined in, I think, otherwise we have a new type of firewall (between code chunks rather than emulations) that we don't want. In other words, your orignal code chunk would be fine if combined with other code defined in another "emulate sh -c ..." chunk. I think that's all we need to get the job done. -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/