From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: Re: [BUG] functions can't create global readonly variables
Date: Fri, 1 Jan 2016 20:27:10 -0800 [thread overview]
Message-ID: <160101202710.ZM1896@torch.brasslantern.com> (raw)
In-Reply-To: <56874393.1010001@inlv.org>
On Jan 2, 4:27am, Martijn Dekker wrote:
}
} It is apparently impossible to create global readonly variables from
} within a function.
typeset -gr var=value
or
readonly -g var=value
} 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:
readonly
Same as typeset -r.
typeset ...
Set or display attributes and values for shell parameters.
A parameter is created for each NAME that does not already refer
to one. When inside a function, a new parameter is created for
every NAME (even those that already exist), and is unset again
when the function completes.
} 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
next prev parent reply other threads:[~2016-01-02 4:27 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 [this message]
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
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=160101202710.ZM1896@torch.brasslantern.com \
--to=schaefer@brasslantern.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).