From: Bart Schaefer <schaefer@brasslantern.com>
To: Bart Schaefer <schaefer@brasslantern.com>,
Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: [PATCH] Fix crash on unset-through-nameref
Date: Tue, 5 Mar 2024 10:42:18 -0800 [thread overview]
Message-ID: <CAH+w=7bJsoJcDz0aNr9G11On4a_fssw3QJHTrtzQnT75n8A-Hw@mail.gmail.com> (raw)
In-Reply-To: <20240305081859.r3qwiyduk2wgkdby@chazelas.org>
On Tue, Mar 5, 2024 at 12:19 AM Stephane Chazelas <stephane@chazelas.org> wrote:
>
> 2024-03-04 15:18:06 -0800, Bart Schaefer:
> > On Mon, Mar 4, 2024 at 11:34 AM Stephane Chazelas <stephane@chazelas.org> wrote:
> > >
> > > It still retained its export attribute.
> >
> > This gets messy because POSIX says that's exactly what's supposed to
> > happen when unsetting an export, even though in native zsh it normally
> > doesn't work that way.
>
> No, I think you're confusing with:
>
> export foo
I'm referring to comments in the C code, e.g.:
* POSIXBUILTINS horror: we need to retain the 'readonly' or 'export'
* flags of an unset parameter.
[...]
if (isset(POSIXBUILTINS)) {
[...]
/* This is handled by createparam():
if (usepm && (pm->node.flags & PM_EXPORTED) && !(off & PM_EXPORTED))
on |= PM_EXPORTED;
*/
> I hate to say this but it seems to me that if this kind of issue
> is not fixable, then it would likely be preferable (from a
> consistency PoV at least) to go for bash/mksh dumber approaches
> where namerefs are just plain scalar variables containing the
> name of another variable (or other lvalue) and having the target
> variable resolved any time the nameref is assigned/referenced
That is in fact exactly how it works, with the addition now that -u
makes it skip upward one scope before resolving.
> (see also
> https://unix.stackexchange.com/questions/640687/prevent-command-substitution-from-running-when-declaring-a-variable/640695#640695
> where namerefs are abused to have a variable with a dynamic
> value).
Although I wasn't aware of that discussion, I had already thought of that:
When RNAME includes an array subscript, the subscript expression is
interpreted at the time ${PNAME} is expanded. Any form of subscript is
allowed, including those that select individual elements, substrings of
scalar strings, or multiple elements as with array slices or the '(i)',
'(I)', '(r)', '(R)' and '(w)' subscript flags. However, the subscript
is evaluated with the NO_EXEC option in effect, so command substitution
and other similar constructs produce no output, although are not
syntactically excluded.
next prev parent reply other threads:[~2024-03-05 18:43 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-04 5:37 Bart Schaefer
2024-03-04 6:29 ` Stephane Chazelas
2024-03-04 8:39 ` Bart Schaefer
2024-03-04 19:34 ` Stephane Chazelas
2024-03-04 19:36 ` Stephane Chazelas
2024-03-04 23:50 ` Bart Schaefer
2024-03-05 8:36 ` Stephane Chazelas
2024-03-04 23:18 ` Bart Schaefer
2024-03-05 8:18 ` Stephane Chazelas
2024-03-05 18:42 ` Bart Schaefer [this message]
2024-03-05 19:38 ` Stephane Chazelas
2024-03-05 23:16 ` Bart Schaefer
2024-03-06 18:21 ` Stephane Chazelas
2024-03-06 19:17 ` Bart Schaefer
2024-03-06 19:37 ` Bart Schaefer
2024-03-05 19:48 ` unset, POSIX and the export attribute (Was: [PATCH] Fix crash on unset-through-nameref) Stephane Chazelas
2024-03-05 19:51 ` [PATCH] Fix crash on unset-through-nameref Stephane Chazelas
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='CAH+w=7bJsoJcDz0aNr9G11On4a_fssw3QJHTrtzQnT75n8A-Hw@mail.gmail.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).