Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
'typeset -p' of assocs (was: Re: PATCH: [key]=value syntax, work in progress)
- X-seq: zsh-workers 41700
- From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: 'typeset -p' of assocs (was: Re: PATCH: [key]=value syntax, work in progress)
- Date: Thu, 14 Sep 2017 06:54:17 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= daniel.shahaf.name; h=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=BMQMkaSsCh8/9hpCQ2 P2rne149LT63juDkTZe/k2QaM=; b=eGQOLDuGMjikg2Z7RHWEz2u9pODSF76duh QuoGjHiE2JvBQ5i0wiKW0QYsPMb0rsPetcax58qq+EyqXyoD7BoP2xcpjnvlyKKe QDGNeuRrTLW39yBiwjuHF1ZQmKQuVjA0IbJ8pI3z4pqVDIwkefLoNCP6shV9C0/K TnxmdBDlr1M8qRM41+wCas6GeQMekX1KwpGduZ8l+4IqoRkNzhsnyE31HKmZeW9G yAu9SfdKgReU0rXHPiyh/fmrA6netvYTmeMoZWqmpbWs2uDOVla+v+fRDhvEL3hf JthPqDhr+icu1tWy9vSiVeVuH3dHiYTYQPcBJj0Iex23Gg4g5i8Q==
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=BMQMkaSsCh8/9hpCQ2 P2rne149LT63juDkTZe/k2QaM=; b=h/VVCeBvjMHSN+rAcqMnJbYNYdeNUfvcJd fRpBaXWDmuufeEWt6yFGxLoWgOdnA3VZ5FH/LhwwMOissiyhp4faVweINuRE2COO yvctCMmEvMdn8VcOIwYZ9cZBeLemXE2xxcRZrCntCnEu207xf5tAg3afFIT7Wj8w 9eGhW2B3YjC7Bu/TDD5lbLAHTEp+fAMnpc6ECJo6HJuq7YVHrJwYak6ZJO4b1LkQ WTseXO4BNUERquzSREUF7sx5gZ7FYKyxFHZNYz6crJtxKm3md+HpUCvTYcKFflnb /EfOF9MUcCWDbHM0fFlkfpt0ov8hbhRDdlVduS3ocnOXj+pFqygw==
- In-reply-to: <30374.1505294044@thecus.kiddle.eu>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20170911215115.6aa27dec@ntlworld.com> <20170912212519.3d873212@ntlworld.com> <30374.1505294044@thecus.kiddle.eu>
Oliver Kiddle wrote on Wed, Sep 13, 2017 at 11:14:04 +0200:
> It would be good to make typeset -p output use this new syntax by default
> for associative arrays because (without other cues like alignment) it
> can be clearer which items in the list are keys and which values.
I've been using a local patch that prints one space between key and its
value, but two spaces between value and the following key:
% typeset -p color
typeset -A color=( 00 none 01 bold 02 faint 03 standout 04 underline 05 blink 07 reverse 08 conceal 22 normal 23 no-standout 24 no-underline 25 no-blink 27 no-reverse 28 no-conceal 30 black 31 red 32 green 33 yellow 34 blue 35 magenta 36 cyan 37 white 39 default 40 bg-black 41 bg-red 42 bg-green 43 bg-yellow 44 bg-blue 45 bg-magenta 46 bg-cyan 47 bg-white 49 bg-default bg-black 40 bg-blue 44 bg-cyan 46 bg-default 49 bg-green 42 bg-grey 40 bg-magenta 45 bg-red 41 bg-white 47 bg-yellow 43 black 30 blink 05 blue 34 bold 01 conceal 08 cyan 36 default 39 faint 02 fg-black 30 fg-blue 34 fg-cyan 36 fg-default 39 fg-green 32 fg-grey 30 fg-magenta 35 fg-red 31 fg-white 37 fg-yellow 33 green 32 grey 30 magenta 35 no-blink 25 no-conceal 28 no-reverse 27 no-standout 23 no-underline 24 none 00 normal 22 red 31 reverse 07 standout 03 underline 04 white 37 yellow 33 )
I think I posted it once, but here it is again.
Cheers,
Daniel
From 714da4bb3a26957cbd65058f7fb4afca85f82ee2 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
Date: Wed, 28 Sep 2016 13:15:04 +0000
Subject: [PATCH] Print two spaces in 'typeset -p' of assocs
(tweaked for upstream 39704/0f5e670cde5f844680a20f986786249dfe983584)
---
Src/params.c | 6 ++++--
Test/V10private.ztst | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/Src/params.c b/Src/params.c
index ef72cba44..39af27c40 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -5298,6 +5298,7 @@ printparamvalue(Param p, int printflags)
if (!(printflags & PRINT_KV_PAIR)) {
putchar('(');
putchar(' ');
+ putchar(' ');
}
{
HashTable ht = p->gsu.h->getfn(p);
@@ -5309,9 +5310,10 @@ printparamvalue(Param p, int printflags)
putchar(')');
break;
}
- if (printflags & PRINT_KV_PAIR)
+ if (printflags & PRINT_KV_PAIR) {
putchar(' ');
- else
+ putchar(' ');
+ } else
putchar('\n');
}
diff --git a/Test/V10private.ztst b/Test/V10private.ztst
index 7ebf5a87f..d1d9b0887 100644
--- a/Test/V10private.ztst
+++ b/Test/V10private.ztst
@@ -128,7 +128,7 @@
print ${(kv)hash_test}
0:private hides value from surrounding scope in nested scope
>typeset -a hash_test=( top level )
->typeset -A hash_test=( in function )
+>typeset -A hash_test=( in function )
>typeset -g -a hash_test=( top level )
>array-local top level
>top level
Messages sorted by:
Reverse Date,
Date,
Thread,
Author