From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3434 invoked from network); 26 Jan 2009 23:07:36 -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 23:07:36 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 30556 invoked from network); 26 Jan 2009 23:07:27 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 26 Jan 2009 23:07:27 -0000 Received: (qmail 5615 invoked by alias); 26 Jan 2009 23:07:20 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26454 Received: (qmail 5605 invoked from network); 26 Jan 2009 23:07:20 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 26 Jan 2009 23:07:20 -0000 Received: from mx.spodhuis.org (redoubt.spodhuis.org [193.202.115.177]) by bifrost.dotsrc.org (Postfix) with ESMTPS id 496DE80271F0 for ; Tue, 27 Jan 2009 00:07:15 +0100 (CET) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=d200807; d=spodhuis.org; h=Received:Date:From:To:Subject:Message-ID:Mail-Followup-To:References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; b=GvBvLMH6p33K3n1ftrjikwvUwCmjLkBVHhn95uEtV6tXSXWMxsJrakMytba8/M2j1p+TTb2HaDHdGTMZV+SCo6hed+w8cJ/wNjGeYEeg5ikenvikQHBzClUT3lvm6IZxU2l7IICOAK0HT0M7DUdtiq2qWNSqp0hOvxlyP4UxNGw=; Received: by smtp.spodhuis.org with local id 1LRaXy-000LMy-3K; Mon, 26 Jan 2009 23:07:14 +0000 Date: Mon, 26 Jan 2009 15:07:13 -0800 From: Phil Pennock To: zsh-workers@sunsite.dk Subject: Re: sourcing a sh file in zsh Message-ID: <20090126230713.GA18017@redoubt.spodhuis.org> Mail-Followup-To: zsh-workers@sunsite.dk References: <200901251156.04815.arvidjaar@gmail.com> <2d460de70901250225g37845bftbbf4b87f12997a7c@mail.gmail.com> <200901251341.44463.arvidjaar@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200901251341.44463.arvidjaar@gmail.com> X-Virus-Scanned: ClamAV 0.92.1/8905/Mon Jan 26 18:29:36 2009 on bifrost X-Virus-Status: Clean On 2009-01-25 at 13:41 +0300, Andrey Borzenkov wrote: > I asked already - why would you want to create non-zsh function inline > in zsh script? Unit tests. If I, or anybody else, is going to make changes for which bugs could crop up far and wide if I/we make mistakes, it will have unit tests written. Writing those tests is much easier if you can include the tests inline. Now, those tests could be arranged to end up in external files before being run, the most obvious mechanism being (assuming -S for Sticky): fn==(cat <<-\HERE # shell bits HERE ) && emulate -SR sh -c "source $fn" but being purely inline would be less grotesque to read. I see the setopt/emulate argument and I can see benefits either way. I went with setopt just because it was what I thought of first and it seems easiest, but that doesn't mean it's best. What I do like with the setopt approach is that there's a way for zsh to test if this is currently the case. Eg, for bash/zsh portability, you could do: if [[ -n $ZSH_VERSION && -o sticky_options ]] since both support [[ conditional ]] and both support -o as a unary prefix test (both using it for testing shell options). -Phil