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
X-Originating-IP: [82.20.18.64]
X-Spam: 0
X-Authority: v=2.1 cv=Sd8KDalu c=1 sm=1 tr=0 a=tQ56d2wE10i0ATcm3CvKvA==:117
 a=tQ56d2wE10i0ATcm3CvKvA==:17 a=NLZqzBF-AAAA:8 a=kj9zAlcOel0A:10
 a=q2GGsy2AAAAA:8 a=SPZUbUZ7SnDh8xosh-EA:9 a=CjuIK1q_8ugA:10
Date: Sat, 2 Jan 2016 18:18:14 +0000
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: [BUG] functions can't create global readonly variables
Message-ID: <20160102181814.3ac8d578@ntlworld.com>
In-Reply-To: <160101202710.ZM1896@torch.brasslantern.com>
References: <56874393.1010001@inlv.org>
	<160101202710.ZM1896@torch.brasslantern.com>
X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-Seq: zsh-workers 37490

On Fri, 1 Jan 2016 20:27:10 -0800
Bart Schaefer <schaefer@brasslantern.com> wrote:
> 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

Bash is treating "typeset -r bar" differently from "readonly bar".
"readonly" affects any existing parameter or creates its own.
I think readonly is equivalent to "typeset -rg", so it stomps
on any existing global, too (unless it was already readonly).

We could make this optional behaviour for compatibility, possibly with
POSIX_BUILTINS which is a real ragbag of POSIX funnies.

pws

