From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23894 invoked from network); 26 Jan 2009 07:51:48 -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; 26 Jan 2009 07:51:48 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 58582 invoked from network); 26 Jan 2009 07:51:42 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 26 Jan 2009 07:51:42 -0000 Received: (qmail 81 invoked by alias); 26 Jan 2009 07:51:36 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26444 Received: (qmail 68 invoked from network); 26 Jan 2009 07:51:36 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 26 Jan 2009 07:51:36 -0000 Received: from vms173003pub.verizon.net (vms173003pub.verizon.net [206.46.173.3]) by bifrost.dotsrc.org (Postfix) with ESMTP id 0D7A88028ACA for ; Mon, 26 Jan 2009 08:51:30 +0100 (CET) Received: from torch.brasslantern.com ([96.238.220.215]) by vms173003.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0KE2001ZYJ5N3KN2@vms173003.mailsrvcs.net> for zsh-workers@sunsite.dk; Mon, 26 Jan 2009 01:51:28 -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 n0Q7pMiX016867 for ; Sun, 25 Jan 2009 23:51:23 -0800 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id n0Q7pMbE016866 for zsh-workers@sunsite.dk; Sun, 25 Jan 2009 23:51:22 -0800 Date: Sun, 25 Jan 2009 23:51:21 -0800 From: Bart Schaefer Subject: Re: sourcing a sh file in zsh In-reply-to: <200901252126.46188.arvidjaar@newmail.ru> To: zsh-workers@sunsite.dk Message-id: <090125235121.ZM16865@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: <200901251156.04815.arvidjaar@gmail.com> <090125042011.ZM25084@torch.brasslantern.com> <200901252126.46188.arvidjaar@newmail.ru> Comments: In reply to Andrey Borzenkov "Re: sourcing a sh file in zsh" (Jan 25, 9:26pm) X-Virus-Scanned: ClamAV 0.92.1/8902/Mon Jan 26 05:21:29 2009 on bifrost X-Virus-Status: Clean On Jan 25, 9:26pm, Andrey Borzenkov wrote: } } Hmm ... not convinced by this example but I realize now that if sticky } emulation is going to be implemented, it could be useful to define } sticky *zsh* function in zsh script. } } I still believe using option is the most simple and straightforward way } to do it. I have a couple of quibbles with doing it with a setopt. The first is one I already mentioned: > It's potential can of worms along the lines of ALL_EXPORT, in that > one can end up accidentally applying a specific option context to a > function definition where one didn't (or shouldn't) mean to do so. It's also unclear (to me) what to do with that setopt when one later encounters "emulate -R". I still think I'd rather that this be a property of "emulate ... -c" rather than an independent setopt. Some remars on your examples ... } For external script library (which is unaware of zsh in any } case) it is simple } } emulate sh -c "setopt sticky_emulation; source /my/shell/library.sh" This doesn't work, does it? "emulate sh -c ..." does not imply a full setopts reset at the end of the eval, only a reset of the emulation mode. Also, are you implying that "emulate sh" would implictly unset that setopt, requiring that it be re-asserted inside the eval? } and zsh script can obviously do } } setopt sticky_emulation } function zsh_func { } ... } } } unsetopt sticky_emulation The trouble with this is that it's not obvious what emulation is being made sticky. In the same way that someone using zsh in "native mode" might want to source a bash script, someone using zsh linked as sh may want to source a zsh script. The script author is either going to have to explicitly call "emulate zsh -c ..." as in your first example, or end up writing local emu=$(emulation) [[ $emu != zsh ]] && emulate zsh { setop sticky_emulation ... } always { unsetopt sticky_emulation emulate $emu } It just seems so much cleaner to wrap it all up in "emulate" in the first place.