zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <stephane.chazelas@gmail.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: local read-only variables (Was:[PATCH] [long] typeset doesn't report tied parameters (and related issues))
Date: Tue, 9 Oct 2018 11:59:47 +0100	[thread overview]
Message-ID: <20181009105947.6dogclbi477aasob@chaz.gmail.com> (raw)
In-Reply-To: <20181007133545.zzkrbc3ed6shnk3e@chaz.gmail.com>

2018-10-07 14:35:46 +0100, Stephane Chazelas:
[...]
> -variable.  Note that in zsh (unlike other shells) it is still possible
                                ^^^^^^^^^^^^^^^^^^^
> -to create a local variable of the same name as this is considered a
> -different variable (though this variable, too, can be marked readonly).
> -)
> +variable.
> +
> +It is still possible to change other attributes of the variable though,
> +some of which like tt(-U) or tt(-Z) would affect the value. More generally,
> +the readonly attribute should not be relied on as a security mechanism.
> +
> +Note that in zsh (like in pdksh but unlike most other shells) it is
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> +still possible to create a local variable of the same name as this is
> +considered a different variable (though this variable, too, can be marked
> +readonly). Special variables that have been made readonly retain their value
> +and readonly attribute when made local.)
[...]

Actually also yash, we might as well remove that "(unlike other
shells)". Note that pdksh has quite a few derivatives (mksh,
posh, openbsd sh (I've not checked there)).

Those shells don't make a distinction for special variables.

Actually I'm not convinced it's useful to treat them
specially in that regard. For instance, if you do "readonly
IFS", you can no longer use library of functions that do some
"local IFS=:" If I add "readonly IFS" to .zshenv,
compaudit/compinit report errors and the shell exits with my
current ~/.zshrc.

See also related POSIX discussion at
http://austingroupbugs.net/view.php?id=767
http://austingroupbugs.net/view.php?id=767#c3735

-- 
Stephane

  parent reply	other threads:[~2018-10-09 11:00 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-24 21:05 [PATCH] typeset -p doesn't report -U (unique) attribute Stephane Chazelas
2018-09-25 16:41 ` Daniel Shahaf
2018-10-07 13:35 ` [PATCH] [long] typeset doesn't report tied parameters (and related issues) Stephane Chazelas
2018-10-08  9:05   ` Peter Stephenson
     [not found]     ` <CACeGjnUhNqca7jLAR0KKSxobzDd+xXdAe4BeUeRpxu2CTp_zkA@mail.gmail.com>
2018-10-08 14:10       ` Peter Stephenson
2018-10-08 14:28         ` Daniel Shahaf
2018-10-08 15:24           ` Peter Stephenson
2018-10-08 15:49             ` Daniel Shahaf
2018-10-08 15:57               ` Bart Schaefer
2018-10-08 16:06                 ` Daniel Shahaf
2018-10-08 16:52                   ` Bart Schaefer
2018-10-08 16:58                     ` Peter Stephenson
2018-10-08 16:02               ` Daniel Shahaf
2018-10-08 16:19                 ` Peter Stephenson
2018-10-08 16:43               ` Peter Stephenson
2018-10-08 16:58                 ` Daniel Shahaf
2018-10-08 17:14                   ` Bart Schaefer
2018-10-08 19:39                     ` Stephane Chazelas
2018-10-09  9:02                   ` Peter Stephenson
     [not found]                   ` <1539075745.1499.2.camel@samsung.com>
2018-10-09  9:44                     ` Peter Stephenson
2018-10-09 16:52                       ` Bart Schaefer
2018-10-09 23:40                         ` Vin Shelton
2018-10-08 15:54             ` Bart Schaefer
2018-10-08 16:40               ` Bart Schaefer
2018-10-09 10:59   ` Stephane Chazelas [this message]
2018-10-11  9:45   ` Oliver Kiddle
2018-10-11 12:46     ` Peter Stephenson

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=20181009105947.6dogclbi477aasob@chaz.gmail.com \
    --to=stephane.chazelas@gmail.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).