From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14138 invoked by alias); 15 May 2017 13:36:26 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 22698 Received: (qmail 14553 invoked from network); 15 May 2017 13:36:26 -0000 X-Qmail-Scanner-Diagnostics: from out4-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.28):SA:0(-0.7/5.0):. Processed in 1.753513 secs); 15 May 2017 13:36:26 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) 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== X-ME-Sender: X-Sasl-enc: 9fUgvB6WVx5Gn+GnMHxEjsAAsRFi4OSrevTv8viSP7lt 1494855372 Date: Mon, 15 May 2017 13:36:10 +0000 From: Daniel Shahaf To: zsh-users@zsh.org Subject: Re: declare -p and -H (hideval) Message-ID: <20170515133610.GA21381@fujitsu.shahaf.local2> References: <170512150302.ZM9904@torch.brasslantern.com> <20170514010444.GA4046@fujitsu.shahaf.local2> <170514102207.ZM15414@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <170514102207.ZM15414@torch.brasslantern.com> User-Agent: Mutt/1.5.23 (2014-03-12) 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.