Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
unset, POSIX and the export attribute (Was: [PATCH] Fix crash on unset-through-nameref)
- X-seq: zsh-workers 52688
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: unset, POSIX and the export attribute (Was: [PATCH] Fix crash on unset-through-nameref)
- Date: Tue, 5 Mar 2024 19:48:57 +0000
- Archived-at: <https://zsh.org/workers/52688>
- In-reply-to: <CAH+w=7bJsoJcDz0aNr9G11On4a_fssw3QJHTrtzQnT75n8A-Hw@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- References: <CAH+w=7ayqWoufueuaHiCzjmzgHtv6VV0m7mEXoHn5nGq4pNOzg@mail.gmail.com> <20240304062914.kn6wquvgog3lefom@chazelas.org> <CAH+w=7b9dcQ4f=71rFZSWBVEJ4bzj7NxzD2-zoj2TkpaCkaCjw@mail.gmail.com> <20240304193409.lv725ah6eifiazzx@chazelas.org> <CAH+w=7ZiTe_hPoBRtHBsRHRvifkiaCJPOCzRSpz0H=XHV8rNbw@mail.gmail.com> <20240305081859.r3qwiyduk2wgkdby@chazelas.org> <CAH+w=7bJsoJcDz0aNr9G11On4a_fssw3QJHTrtzQnT75n8A-Hw@mail.gmail.com>
2024-03-05 10:42:18 -0800, Bart Schaefer:
> On Tue, Mar 5, 2024 at 12:19 AM Stephane Chazelas <stephane@xxxxxxxxxxxx> wrote:
> >
> > 2024-03-04 15:18:06 -0800, Bart Schaefer:
> > > On Mon, Mar 4, 2024 at 11:34 AM Stephane Chazelas <stephane@xxxxxxxxxxxx> 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;
> */
[...]
But AFAICT, that's about the "export var" when var is not
previously set. You can't unset a readonly variable anyway.
zsh retaining the export attribute of a variable upon unset
would make it non-compliant.
POSIX is not ambiguous on that. See
https//pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/V3_chap02.html#unset
"unset - unset values and attributes of variables and functions"
"Read-only variables cannot be unset."
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author