summaryrefslogtreecommitdiff
path: root/Src/params.c
diff options
context:
space:
mode:
authorBart Schaefer <schaefer@zsh.org>2024-02-20 20:16:03 -0800
committerBart Schaefer <schaefer@zsh.org>2024-02-20 20:16:03 -0800
commit6b21e5c0e201876f6659b563b56da9a993ae6c03 (patch)
treea8495275a78da67503895da1a30df15ee676152f /Src/params.c
parenta6ea12286709273e7896916dc8a107cd52f01d26 (diff)
downloadzsh-6b21e5c0e201876f6659b563b56da9a993ae6c03.tar.gz
zsh-6b21e5c0e201876f6659b563b56da9a993ae6c03.zip
52559: revise "typeset -p" with respect to local readonly special parameters
Update doc and tests to describe handling of global readonly specials and to account for side-effects on zsh/param/private.
Diffstat (limited to 'Src/params.c')
-rw-r--r--Src/params.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/Src/params.c b/Src/params.c
index fce3af940..b329d2079 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -5896,6 +5896,7 @@ static const struct paramtypes pmtypes[] = {
{ PM_ARRAY, "array", 'a', 0},
{ PM_HASHED, "association", 'A', 0},
{ 0, "local", 0, PMTF_TEST_LEVEL},
+ { PM_HIDE, "hide", 'h', 0 },
{ PM_LEFT, "left justified", 'L', PMTF_USE_WIDTH},
{ PM_RIGHT_B, "right justified", 'R', PMTF_USE_WIDTH},
{ PM_RIGHT_Z, "zero filled", 'Z', PMTF_USE_WIDTH},
@@ -6025,13 +6026,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
@@ -6064,8 +6073,19 @@ printparamnode(HashNode hn, int printflags)
for (pmptr = pmtypes, i = 0; i < PMTYPES_SIZE; i++, pmptr++) {
int doprint = 0;
if (pmptr->flags & PMTF_TEST_LEVEL) {
- if (p->level)
+ if (p->level) {
+ /*
+ if ((p->node.flags & PM_SPECIAL) &&
+ (p->node.flags & PM_LOCAL) &&
+ !(p->node.flags & PM_HIDE)) {
+ if (doneminus)
+ putchar(' ');
+ printf("+h ");
+ doneminus = 0;
+ }
+ */
doprint = 1;
+ }
} else if ((pmptr->binflag != PM_EXPORTED || p->level ||
(p->node.flags & (PM_LOCAL|PM_ARRAY|PM_HASHED))) &&
(p->node.flags & pmptr->binflag))