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

[PATCH] typeset -p doesn't report -U (unique) attribute



From:
https://unix.stackexchange.com/questions/470956/how-to-print-all-the-attributes-of-a-zsh-parameter


$ typeset -U a=(x x)
$ typeset -p a
typeset -a a=( x )

Expected:

$ typeset -p a
typeset -aU a=( x )


diff --git a/Src/params.c b/Src/params.c
index a1c299f60..f7ecff32a 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -5854,20 +5854,27 @@ printparamnode(HashNode hn, int printflags)
 		if ((pmptr->flags & PMTF_USE_BASE) && p->base) {
 		    printf("%d ", p->base);
 		    doneminus = 0;
 		}
 		if ((pmptr->flags & PMTF_USE_WIDTH) && p->width) {
 		    printf("%d ", p->width);
 		    doneminus = 0;
 		}
 	    }
 	}
+	if (p->node.flags & PM_UNIQUE) {
+	    if (!doneminus) {
+	      putchar('-');
+	      doneminus = 1;
+	    }
+	    putchar('U');
+	}
 	if (doneminus)
 	    putchar(' ');
     }
 
     if ((printflags & PRINT_NAMEONLY) ||
 	((p->node.flags & PM_HIDEVAL) && !(printflags & PRINT_INCLUDEVALUE))) {
 	zputs(p->node.nam, stdout);
 	putchar('\n');
     } else {
 	if (printflags & PRINT_KV_PAIR) {



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