Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Regression of typeset output with "private"



On Fri, Feb 16, 2024 at 12:09 PM Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> Tangentially, I think there's a regression with "private":
>
> () {
>   zmodload zsh/param/private
>   private foo=local
>   typeset -p foo
> }
>
> That now prints nothing, whereas in e.g. 5.7 it would say
>   typeset foo=local
> which isn't precisely accurate either.

Traced this to here:

>> commit f99f7dca7552d21782354f675c0741896c9785f1
>> Author: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
>> Date:   Mon Oct 8 10:10:42 2018 +0100
>>
>>     43616: Various parameter setting and display fixes.

Specifically to this (pardon any excessive gmail line wrapping):

-    if (printflags & PRINT_TYPESET) {
-       if ((p->node.flags & (PM_READONLY|PM_SPECIAL)) ==
-           (PM_READONLY|PM_SPECIAL) ||
-           (p->node.flags & PM_AUTOLOAD)) {
+    if (printflags & (PRINT_TYPESET|PRINT_POSIX_READONLY|PRINT_POSIX_EXPORT)) {
+       if (p->node.flags & (PM_RO_BY_DESIGN|PM_AUTOLOAD)) {
            /*
             * It's not possible to restore the state of
             * these, so don't output.
             */
            return;
        }


Leaving out PM_RO_BY_DESIGN restores the old behavior.  I understand
the motivation here (the comment), and if we were printing all values
("typeset -p" with no other arguments) it would make more sense, but
in the context of explicitly asking for "typeset -p foo" it surely
ought to print ... something?




Messages sorted by: Reverse Date, Date, Thread, Author