Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: declare -p and -H (hideval)
- X-seq: zsh-users 22698
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: declare -p and -H (hideval)
- Date: Mon, 15 May 2017 13:36:10 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=5Nu/lJKptoHSIF4rMXng4M7QLver4ndAhlsr1WSd0CI=; b=b31frP2O kUgJa7pI8lcvquLVMBKLbMqx4G4EJN35XHpLpoAtnlHqajqkAxPtYfuehWAN76NS Z1OxTnS9R3uQFPNk0ad+Saee3S0o1lSNUWIvTFAMwyb/GGfxvger+jlXpI9hAaqL wZg6onA7bGdQCsRl1byLcaRQlE3qikAMBNOVlnE4OXpOKt7zBTuYqvqNf+Use0hg Tg1qDrrBUdqWEIcW0guOoGwGuPnPJrNAav4lFEAx0niXUWEgdz4Tj26VQVdofRsj 3vpy4HsXZitUYcxAZ0BC+LN4acBb3qvS4GSJHh7P0fDILq6wFlMrCpbRFC8yfBiz S3kqUPe0aCmDPg==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc:x-sasl-enc; s= fm1; bh=5Nu/lJKptoHSIF4rMXng4M7QLver4ndAhlsr1WSd0CI=; b=QGCr5S8G fLGWTivGI1W6Vih5Bq/qhHDLKoo868OHLLGfUtRyT3bvtnyqnHsqz+gxWYqOz9dY EGTGfbP3Q1HW5TQeZUfX6kfTX3ce7/4/hS8fvYZ9YSGSI7+XlJV3gTH7Yf/pu0Ty pk2X4SNW8fEU3j5kHcF3e2YoNr0Fith6Y4WqdhJyWZHZRZKKg2CJ+7VtITOzShtb SfZ2EGnJP/twkduUSmnq+cidUFmGlI7h53A4TuG6+OHWj1Oy2GRgBuqY1EvDQPxn hn/sx8WbtmzViW9o0+tBuj23yOi9+GW1LNBcGIf29rktd9PIcytWvXWJb+Ima0Zg EQoruQJqy4lEqw==
- In-reply-to: <170514102207.ZM15414@torch.brasslantern.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <etPan.5915e115.238e1f29.6b4c@MacMini.local> <170512150302.ZM9904@torch.brasslantern.com> <20170514010444.GA4046@fujitsu.shahaf.local2> <170514102207.ZM15414@torch.brasslantern.com>
Bart Schaefer wrote on Sun, May 14, 2017 at 10:22:07 -0700:
> On May 14, 1:04am, Daniel Shahaf wrote:
> }
> } The fact remains that the "does not apply" clause that Sebastian quoted
> } does not match the implementation. The question is just which of them
> } should be fixed to match the other. (Code archeology may answer this,
> } but I'm not going to do it tonight.)
>
> Based on git history, -p has always taken precendence here.
Ah, I see: 'typeset k' ignores -H but 'typeset -p k' does not.
> It'd be quite simple to make -pm behave differently with respect to the
> value. However, I also note that PM_HIDEVAL is not one of the "type
> flags" that is output by "typeset -p" -- it only emits flags for things
> like array, integer, padding/alignment, etc. So that would presumably
> also need to change, which begins to get more involved.
I went down the rabbit hole, and it seems pretty sane so far:
[[[
% Z -c 'typeset -H k=v; typeset | grep -w k; typeset + | grep -w k; typeset -p | grep -w k' | grep -v ZSH_EXECUTION_STRING
hidden value k
hidden value k
typeset -H k
% Z -c 'typeset -H k=v; typeset k; typeset -p k; typeset -m k; typeset -pm k'
k=v
typeset -H k=v
k=v
typeset -H k=v
]]]
[[[
diff --git a/Src/builtin.c b/Src/builtin.c
index 86c79bb..a762987 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2617,6 +2617,7 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
printflags |= PRINT_TYPESET;
hasargs = *argv != NULL || (assigns && firstnode(assigns));
if (!hasargs) {
+ printflags |= PRINT_ALL;
if (!OPT_ISSET(ops,'p')) {
if (!(on|roff))
printflags |= PRINT_TYPE;
diff --git a/Src/params.c b/Src/params.c
index 3e423cd..2c3c2bd 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -5483,7 +5483,9 @@ static const struct paramtypes pmtypes[] = {
{ PM_UPPER, "uppercase", 'u', 0},
{ PM_READONLY, "readonly", 'r', 0},
{ PM_TAGGED, "tagged", 't', 0},
- { PM_EXPORTED, "exported", 'x', 0}
+ { PM_EXPORTED, "exported", 'x', 0},
+ { PM_HIDE, "hiding", 'h', 0},
+ { PM_HIDEVAL, "hidden value", 'H', 0}
};
#define PMTYPES_SIZE ((int)(sizeof(pmtypes)/sizeof(struct paramtypes)))
@@ -5648,7 +5650,8 @@ printparamnode(HashNode hn, int printflags)
}
if ((printflags & PRINT_NAMEONLY) ||
- ((p->node.flags & PM_HIDEVAL) && !(printflags & PRINT_INCLUDEVALUE))) {
+ ((p->node.flags & PM_HIDEVAL) && !(printflags & PRINT_INCLUDEVALUE) &&
+ (printflags & PRINT_ALL))) {
zputs(p->node.nam, stdout);
putchar('\n');
} else {
diff --git a/Src/zsh.h b/Src/zsh.h
index f77204e..93d515f 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -2077,7 +2077,8 @@ typedef groupset *Groupset;
#define PRINT_LIST (1<<2)
#define PRINT_KV_PAIR (1<<3)
#define PRINT_INCLUDEVALUE (1<<4)
-#define PRINT_TYPESET (1<<5)
+#define PRINT_TYPESET (1<<5) /* typeset -p */
+#define PRINT_ALL (1<<11) /* printing all parameters, not just named ones nor -m */
/* flags for printing for the whence builtin */
#define PRINT_WHENCE_CSH (1<<6)
]]]
Whether to commit this is another question: it'd break an explicitly
documented property of the -p flag, which people might conceivably rely
on: currently,
.
% typeset -H foo=1 bar=2
% store=`typeset -p foo bar`
⋮
% eval $store > /dev/null
.
wouldn't change $foo's value.
Thoughts?
Daniel
P.S. Haven't updated test expectations yet.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author