From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: [BUG] functions can't create global readonly variables
Date: Sat, 2 Jan 2016 18:18:14 +0000 [thread overview]
Message-ID: <20160102181814.3ac8d578@ntlworld.com> (raw)
In-Reply-To: <160101202710.ZM1896@torch.brasslantern.com>
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
next prev parent reply other threads:[~2016-01-02 18:18 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 [this message]
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
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=20160102181814.3ac8d578@ntlworld.com \
--to=p.w.stephenson@ntlworld.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).