From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: Regression of typeset output with "private"
Date: Sun, 18 Feb 2024 11:35:29 -0800 [thread overview]
Message-ID: <CAH+w=7ayzdwWkmGDbMMSWJceYbL+=4+rNNV2i-EhuDD=hnQSdg@mail.gmail.com> (raw)
In-Reply-To: <CAH+w=7YCPhUV=vRW2ue46N2+ZCpE+HeS_nG1CR36ZqwnV06hNA@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1050 bytes --]
On Fri, Feb 16, 2024 at 10:29 PM Bart Schaefer
<schaefer@brasslantern.com> wrote:
>
> Traced this to here:
>
> >> commit f99f7dca7552d21782354f675c0741896c9785f1
> >> Author: Peter Stephenson <p.stephenson@samsung.com>
> >> Date: Mon Oct 8 10:10:42 2018 +0100
> >>
> >> 43616: Various parameter setting and display fixes.
>
> in the context of explicitly asking for "typeset -p foo" it surely
> ought to print ... something?
How about this? It skips PM_RO_BY_DESIGN for any parameter not
declared in the same scope where "typeset -p" is being run. This
means that in addition to displaying parameters declared private,
it'll show cases where "local +h" has been used to shadow a special.
No doc included in this patch, but we should probably mention
somewhere that "typeset -p" no longer displays values for the special
parameters $!, $#, $-, $*, $@, $$, $?, $ARGC, etc. (unless "local +h"
per above) This is actually a change in 5.9 vs. 5.8 that was not
included in the NEWS file. Should it also be in the Doc?
[-- Attachment #2: private-p.txt --]
[-- Type: text/plain, Size: 1932 bytes --]
diff --git a/Src/params.c b/Src/params.c
index a722a20f6..ee5733af4 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -6025,13 +6025,21 @@ printparamnode(HashNode hn, int printflags)
printflags |= PRINT_NAMEONLY;
if (printflags & (PRINT_TYPESET|PRINT_POSIX_READONLY|PRINT_POSIX_EXPORT)) {
- if (p->node.flags & (PM_RO_BY_DESIGN|PM_AUTOLOAD)) {
+ if (p->node.flags & PM_AUTOLOAD) {
/*
* It's not possible to restore the state of
* these, so don't output.
*/
return;
}
+ if (p->node.flags & PM_RO_BY_DESIGN) {
+ /*
+ * Compromise: cannot be restored out of context,
+ * but show anyway if printed in scope of declaration
+ */
+ if (p->level != locallevel || p->level == 0)
+ return;
+ }
/*
* The zsh variants of export -p/readonly -p also report other
* flags to indicate other attributes or scope. The POSIX variants
diff --git a/Test/V10private.ztst b/Test/V10private.ztst
index 9eeda0f47..11ac92f03 100644
--- a/Test/V10private.ztst
+++ b/Test/V10private.ztst
@@ -328,6 +328,7 @@ F:future revision will create a global with this assignment
F:See K01nameref.ztst up-reference part 5
F:Here ptr1 finds private ptr2 by scope mismatch
>typeset -n ptr1=ptr2
+>typeset -n ptr2
*?*read-only variable: ptr2
() {
@@ -348,10 +349,12 @@ F:See K01nameref.ztst up-reference part 5
F:Here ptr1 finds private ptr2 by scope mismatch
F:Assignment silently fails, is that correct?
>typeset -n ptr1=ptr2
+>typeset -n ptr2=''
>ptr1=ptr2
>ptr1=
>ptr2=
>typeset -n ptr1=ptr2
+>typeset -n ptr2=''
*?*no such variable: ptr2
typeset ptr2
@@ -372,11 +375,13 @@ F:Assignment silently fails, is that correct?
F:See K01typeset.ztst up-reference part 5
F:Here ptr1 points to global ptr2 so assignment succeeds
>typeset -n ptr1=ptr2
+>typeset -n ptr2
>ptr1=ptr2
>ptr2=val
>ptr1=val
>ptr2=val
>typeset -n ptr1=ptr2
+>typeset -n ptr2
>typeset ptr2=val
() {
next prev parent reply other threads:[~2024-02-18 19:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-16 20:09 Is this intentional behavior of typeset -g ? Bart Schaefer
2024-02-17 6:29 ` Regression of typeset output with "private" Bart Schaefer
2024-02-18 19:35 ` Bart Schaefer [this message]
2024-02-20 4:54 ` [PATCH] (take 2) Local specials and " Bart Schaefer
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=7ayzdwWkmGDbMMSWJceYbL+=4+rNNV2i-EhuDD=hnQSdg@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).