From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1539 invoked from network); 30 Jan 2009 04:32:38 -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.5 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; 30 Jan 2009 04:32:38 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 56173 invoked from network); 30 Jan 2009 04:32:25 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 30 Jan 2009 04:32:25 -0000 Received: (qmail 4008 invoked by alias); 30 Jan 2009 04:32:20 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26488 Received: (qmail 3999 invoked from network); 30 Jan 2009 04:32:19 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 30 Jan 2009 04:32:19 -0000 Received: from vms173003pub.verizon.net (vms173003pub.verizon.net [206.46.173.3]) by bifrost.dotsrc.org (Postfix) with ESMTP id 4D72480271F0 for ; Fri, 30 Jan 2009 05:32:05 +0100 (CET) Received: from torch.brasslantern.com ([96.238.220.215]) by vms173003.mailsrvcs.net (Sun Java(tm) System Messaging Server 6.3-2.01 (built Jun 13 2007; 32bit)) with ESMTPA id <0KE900MAQO9RZLY0@vms173003.mailsrvcs.net> for zsh-workers@sunsite.dk; Thu, 29 Jan 2009 22:25:04 -0600 (CST) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id n0U4P1pv021286 for ; Thu, 29 Jan 2009 20:25:03 -0800 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id n0U4P1xd021285 for zsh-workers@sunsite.dk; Thu, 29 Jan 2009 20:25:01 -0800 From: Bart Schaefer Message-id: <090129202501.ZM21284@torch.brasslantern.com> Date: Thu, 29 Jan 2009 20:25:01 -0800 In-reply-to: <200901261949.54010.arvidjaar@gmail.com> Comments: In reply to Andrey Borzenkov "Re: sourcing a sh file in zsh" (Jan 26, 7:49pm) References: <200901252126.46188.arvidjaar@newmail.ru> <090125235121.ZM16865@torch.brasslantern.com> <200901261949.54010.arvidjaar@gmail.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@sunsite.dk Subject: Re: sourcing a sh file in zsh MIME-version: 1.0 Content-type: text/plain; charset=us-ascii X-Virus-Scanned: ClamAV 0.92.1/8920/Thu Jan 29 19:30:26 2009 on bifrost X-Virus-Status: Clean Getting back to this a bit later ... On Jan 26, 7:49pm, Andrey Borzenkov wrote: } Subject: Re: sourcing a sh file in zsh } } On 26 0x044F0x043D0x04320x04300x04400x044F 2009 10:51:21 Bart Schaefer wrote: } > } > } emulate sh -c "setopt sticky_emulation; source } > /my/shell/library.sh" } > } > This doesn't work, does it? } } Right, because this option does not exist. Or do you mean something } else? I meant I didn't think it would do what you intended, but: } > "emulate sh -c ..." does not imply a } > full setopts reset at the end of the eval, only a reset of the } > emulation mode. } } It does. This is exactly what LOCAL_OPTIONS does as well. Obviously I understand that's what LOCAL_OPTIONS does, but I never meant for that to be what "emulate" did. Apparently I misread your patch. I expected an approximate equivalence between emulate sh -c "echo foo" and { emu=$(emulate) emulate sh eval "echo foo" } always { emulate $emu } I *didn't* expect an equivalence to function scopes with respect to any setopts that aren't normally affected by changing the emulation. Having said that, however, I'm left undecided as to whether it really makes any difference. I admit there are cases where I wished I had a LOCAL_OPTIONS scope and *not* a "local" parameter scope, a result for which this form of emulate can be abused. However, I do think that (if the implementation remains as-is) the documentation needs to be clearer that the *entire* setopt context is restored. Currently it says only that "Emulation will be restored".