From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12984 invoked by alias); 10 Nov 2010 12:08:11 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28400 Received: (qmail 7581 invoked from network); 10 Nov 2010 12:08:08 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Wed, 10 Nov 2010 11:10:25 +0000 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: static vs. dynamic scoping Message-ID: <20101110111025.017bd7ba@pwslap01u.europe.root.pri> In-Reply-To: <4CD9C64E.8060307@redhat.com> References: <4CD9C64E.8060307@redhat.com> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.6 (GTK+ 2.20.1; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 10 Nov 2010 11:10:26.0136 (UTC) FILETIME=[E05EFD80:01CB80C7] X-Scanned-By: MailControl A_10_80_00 (www.mailcontrol.com) on 10.68.0.116 I might as well copy what I sent to the Austin group list this morning for the majority not following that... The "other" matters referred to are, to summarise very briefly, basically whether foo="a b" export x=$foo causes x to be set to "a b". Currently POSIX implies it doesn't. From: Peter Stephenson To: austin-group-l@opengroup.org Subject: Re: Word splitting in 'export' arguments and adding local Date: Wed, 10 Nov 2010 10:13:20 +0000 On Tue, 09 Nov 2010 22:34:22 -0500 Chet Ramey wrote: > Bash uses dynamic scoping and, as I have existing users and scripts > that take advantage of it, I have no intention of changing that. I > know zsh uses dynamic scoping and there are scripts that make > extensive use of it. That's correct about zsh: the completion functions supplied with the shell rely (very) heavily on dynamic scoping and we certainly wouldn't be changing that. I can't see any likelihood of writing a completely different additional implementation of local variables with static scoping for POSIX mode. It might be possible as an option to hide and uncover variables when entering nested functions to simulate static scoping without a complete rewrite, but I really haven't thought it through and it's not likely to be a high priority. It might also be worth reminding people that POSIX support was rather an afterthought for zsh but we try to keep that mode working where possible. I don't think any of the other matters being discusses here are a big issue for zsh in POSIX mode, however. If you happen to be investigating this in zsh, the following options are relevant: SH_WORD_SPLIT turn on splitting of substitutions as done by default in other shells KSH_TYPESET turn off argument splitting on assignments for typeset, local, etc. if SH_WORD_SPLIT is on. Note this is not turned on automatically in POSIX mode (for reasons anyone following this thread will realise). MAGIC_EQUAL_SUBST ~-expansion (and zsh-specific =-expansion, if applicable) are active after all "=", and also after following :, regardless of the command. The example in the manual is echo foo=~/bar:~/rod expands both ~'s. The effect of this option has expanded somewhat during the life of zsh. (I'm not suggesting this would ever be POSIX-compatible.) pws Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom