Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au
X-Spam-Level: 
X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham
	autolearn_force=no version=3.4.0
Message-ID: <5688276D.9000009@inlv.org>
Date: Sat, 02 Jan 2016 20:39:25 +0100
From: Martijn Dekker <martijn@inlv.org>
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:31.0) Gecko/20100101 Thunderbird/31.2.0
MIME-Version: 1.0
To: zsh-workers@zsh.org
Subject: Re: [BUG] functions can't create global readonly variables
References: <56874393.1010001@inlv.org> <160101202710.ZM1896@torch.brasslantern.com>
In-Reply-To: <160101202710.ZM1896@torch.brasslantern.com>
Content-Type: text/plain; charset=windows-1252
Content-Transfer-Encoding: 7bit
X-Seq: zsh-workers 37492

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.

