From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26013 invoked from network); 21 Jan 2009 04:49:11 -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; 21 Jan 2009 04:49:11 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 99706 invoked from network); 21 Jan 2009 04:49:04 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 21 Jan 2009 04:49:04 -0000 Received: (qmail 22781 invoked by alias); 21 Jan 2009 04:48:58 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26384 Received: (qmail 22764 invoked from network); 21 Jan 2009 04:48:57 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 21 Jan 2009 04:48:57 -0000 Received: from vms173009pub.verizon.net (vms173009pub.verizon.net [206.46.173.9]) by bifrost.dotsrc.org (Postfix) with ESMTP id CB41980271F0 for ; Wed, 21 Jan 2009 05:48:53 +0100 (CET) Received: from torch.brasslantern.com ([96.238.220.215]) by vms173009.mailsrvcs.net (Sun Java System Messaging Server 6.2-6.01 (built Apr 3 2006)) with ESMTPA id <0KDT00AR515GR8L2@vms173009.mailsrvcs.net> for zsh-workers@sunsite.dk; Tue, 20 Jan 2009 22:44:05 -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 n0L4monu015283 for ; Tue, 20 Jan 2009 20:48:51 -0800 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id n0L4moBd015282 for zsh-workers@sunsite.dk; Tue, 20 Jan 2009 20:48:50 -0800 Date: Tue, 20 Jan 2009 20:48:50 -0800 From: Bart Schaefer Subject: Re: sourcing a sh file in zsh In-reply-to: <20090120194847.58a30c9a@pws-pc> To: zsh-workers@sunsite.dk Message-id: <090120204850.ZM15281@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=us-ascii References: <090116075615.ZM21871@torch.brasslantern.com> <200901161939.54651.arvidjaar@newmail.ru> <090116102934.ZM22119@torch.brasslantern.com> <20090117035923.GA64953@redoubt.spodhuis.org> <090116210045.ZM22623@torch.brasslantern.com> <20090117055559.GA60339@redoubt.spodhuis.org> <090117121501.ZM8940@torch.brasslantern.com> <20090120194847.58a30c9a@pws-pc> Comments: In reply to Peter Stephenson "Re: sourcing a sh file in zsh" (Jan 20, 7:48pm) X-Virus-Scanned: ClamAV 0.92.1/8881/Tue Jan 20 15:48:51 2009 on bifrost X-Virus-Status: Clean On Jan 20, 7:48pm, Peter Stephenson wrote: } } > Combined with allowing "emulate" create a scope and run a command } > in that scope, is there anything else you'd need? } > } > PWS, any comment on how difficult it would be to extend "emulate" in } > this way? Would it require promoting emulate to a keyword? } } I haven't heard anything that sounds particularly difficult, although it } obviously needs a firm grip on what's being set at what point. I don't } see why emulate should have to behave specially as far as syntax is } concerned, as long as its behaviour is well defined. My thought was that emulate behave syntactically something like "exec": % var="a string with spaces" % emulate sh print -l $var a string with spaces There'd also be an option to go with -L and -R to cause the emulation mode to become "sticky" in the wordcode for any function defined "in the scope of" the emulate ("-X" used here as placeholder): % emulate -X sh function foo { print -l $@ } % foo "more spaces here" more spaces here It may be going too far to make emulate a syntactic element like that. So the next best thing is if it works more like "eval": % emulate -X sh 'foo() { print -l $@ }' The most frequent intended usage being % emulate -X sh source ~/some_bash_library.sh which would apply the "sticky emulation" to all the functions that might be defined by some_bash_library.sh. Maybe the sticky-option isn't even needed, maybe it should just always become sticky when called with a command as arguments. There are all sorts of variants of this that I'd find acceptable. One that might be esthetically pleasing would be using a -c option, as if you were running the shell in question: % emulate ksh -c 'source ~/some_ksh_library.sh' That's probably enough examples.