From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9349 invoked from network); 31 Jan 2009 08:32:54 -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=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 08:32:54 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 35000 invoked from network); 31 Jan 2009 08:32:46 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 31 Jan 2009 08:32:46 -0000 Received: (qmail 25146 invoked by alias); 31 Jan 2009 08:32:41 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 26498 Received: (qmail 25134 invoked from network); 31 Jan 2009 08:32:40 -0000 Received: from bifrost.dotsrc.org (130.225.254.106) by sunsite.dk with SMTP; 31 Jan 2009 08:32:40 -0000 Received: from mail-bw0-f23.google.com (mail-bw0-f23.google.com [209.85.218.23]) by bifrost.dotsrc.org (Postfix) with ESMTP id EC30C80271F0 for ; Sat, 31 Jan 2009 09:32:35 +0100 (CET) Received: by bwz4 with SMTP id 4so51801bwz.21 for ; Sat, 31 Jan 2009 00:32:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date :user-agent:references:in-reply-to:mime-version:content-type :content-transfer-encoding:message-id; bh=9hcQ+Yl5UbObpMPvOlDOpu/9YCWRTdehNEpAjL/jFHo=; b=MxeL16eP/DGoU6TuOm5ExLaQ+Y8LqfbDUz3ZjnzPU9WrsJBy4c340u7vBr3jrZeCOC 4Jg6Do8D7pZB/lCOF27pkjAfu8fCqpjCmVH5yr0tzzDWT8yWfGM4z19jsEGFFz2PTApT DQuC3sogTFJrWxC/NTi5CVnj9lcToW7n59wSo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:user-agent:references:in-reply-to:mime-version :content-type:content-transfer-encoding:message-id; b=tD8MphHZ6DcqWHTdcERxQZZfVqZdqdUb+FEeRv5lqaA+jubmZ98pT3kRk/d13NppwC /gzPL6mi0bV6uAmkK2I1IOjgAar8IYTG6QKsu/cTGQRR9LUjWz8lV4hL55Xy41xmT+kn F9z+WhcPyOxybk2XDKyILO11NN7hBIQ2Zdv1U= Received: by 10.86.4.14 with SMTP id 14mr206139fgd.27.1233390755366; Sat, 31 Jan 2009 00:32:35 -0800 (PST) Received: from cooker.localnet (ppp91-77-237-43.pppoe.mtu-net.ru [91.77.237.43]) by mx.google.com with ESMTPS id l12sm312690fgb.21.2009.01.31.00.32.33 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 31 Jan 2009 00:32:34 -0800 (PST) From: Andrey Borzenkov To: zsh-workers@sunsite.dk Subject: Re: sourcing a sh file in zsh Date: Sat, 31 Jan 2009 11:32:20 +0300 User-Agent: KMail/1.11.0 (Linux/2.6.29-rc3-1avb; KDE/4.2.0; i686; ; ) References: <200901261949.54010.arvidjaar@gmail.com> <090129202501.ZM21284@torch.brasslantern.com> In-Reply-To: <090129202501.ZM21284@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="nextPart1699356.OW1lMFk0ER"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit Message-Id: <200901311132.28144.arvidjaar@gmail.com> X-Virus-Scanned: ClamAV 0.92.1/8929/Sat Jan 31 04:20:45 2009 on bifrost X-Virus-Status: Clean --nextPart1699356.OW1lMFk0ER Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 30 of January 2009 07:25:01 Bart Schaefer wrote: > 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 apologize for not being clear enough as well. Discussion actually started with the this code (not exactly, but): function run_on_sh_mode { emulate -L sh $* } So I intended emulate -c to be replacement for above without possible=20 scoping issues (because e.g. startup scripts here do set quite a lot of=20 variables). > I expected an approximate equivalence between > > emulate sh -c "echo foo" > > and > > { > emu=3D$(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. > This is doable. I did not quite like it because my primary intention was=20 to run foreign code. In which case I definitely would not like this code=20 by accident change shell behaviour. So it is sort of sandbox. Another observation that my intended usage was almost exclusively=20 "emulate -R"; in which case to revert this you have to reset *all*=20 options anyway. > 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. > I think we need to sort this out before usage sticks. So let's consider what we get emulate -L -c "command" implicitly set LOCAL_OPTIONS before executing command emulate [-R] -c "command" implicitly do "emulate [-R] oldemulation" after executing command Do I miss something? Is it what you intend? > 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". I will update it. --nextPart1699356.OW1lMFk0ER Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEABECAAYFAkmEDJQACgkQR6LMutpd94zaYgCgkqr94qmdcwRYSD9BDo0qeoxk EIMAoKigagMJa/nmnRkwQuQ65Y4Sg8Jx =1HCM -----END PGP SIGNATURE----- --nextPart1699356.OW1lMFk0ER--