zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <Peter.Stephenson@csr.com>
To: zsh-workers@zsh.org
Subject: Re: static vs. dynamic scoping
Date: Wed, 10 Nov 2010 11:10:25 +0000	[thread overview]
Message-ID: <20101110111025.017bd7ba@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <4CD9C64E.8060307@redhat.com>

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 <pws@csr.com>
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 <chet.ramey@case.edu> 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


  reply	other threads:[~2010-11-10 12:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-09 22:08 Eric Blake
2010-11-10 11:10 ` Peter Stephenson [this message]
2010-11-10 16:50 ` Bart Schaefer
2010-11-10 17:28   ` Eric Blake
2010-11-10 17:43     ` Eric Blake
2011-05-29  6:38     ` Thorsten Glaser
2010-11-10 17:22 ` Bart Schaefer
2010-11-10 17:30   ` Eric Blake
2010-11-10 18:01     ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101110111025.017bd7ba@pwslap01u.europe.root.pri \
    --to=peter.stephenson@csr.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).