zsh-workers
 help / color / mirror / code / Atom feed
From: Martijn Dekker <martijn@inlv.org>
To: zsh-workers@zsh.org
Subject: Re: [BUG] functions can't create global readonly variables
Date: Sat, 02 Jan 2016 20:39:25 +0100	[thread overview]
Message-ID: <5688276D.9000009@inlv.org> (raw)
In-Reply-To: <160101202710.ZM1896@torch.brasslantern.com>

Bart Schaefer schreef op 02-01-16 om 05:27:
> On Jan 2,  4:27am, Martijn Dekker wrote:
> } I don't know if this is intended behaviour for native zsh mode; the
> } 'zshbuiltins' man page does not mention anything about this.
> 
> Of course it does:

I blame insufficient caffeination at the time of writing.

> } But it is certainly a bug for POSIX/'emulate sh' mode.
> 
> I think it's undefined behavior for POSIX/'emulate sh'.  Certainly bash
> agrees with us:
> 
> $ foo() { typeset -r bar; typeset -p bar; }
> $ foo
> declare -r bar
> $ typeset -p bar
> bash: typeset: bar: not found

But 'typeset' is not POSIX. When using the POSIX 'readonly' special
builtin, bash acts like other POSIX shells and unlike zsh:

$ foo() { readonly bar=baz; typeset -p bar; }
$ foo
declare -r bar="baz"
$ typeset -p bar
declare -r bar="baz"

Thanks,

- M.


      parent reply	other threads:[~2016-01-02 19:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-02  3:27 Martijn Dekker
2016-01-02  4:27 ` Bart Schaefer
2016-01-02 18:18   ` Peter Stephenson
2016-01-02 20:36     ` Bart Schaefer
2016-01-03 19:00       ` Peter Stephenson
2016-01-03 19:21         ` Bart Schaefer
2016-01-02 19:39   ` Martijn Dekker [this message]

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=5688276D.9000009@inlv.org \
    --to=martijn@inlv.org \
    --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).