From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18237 invoked by alias); 4 Dec 2015 15:34:29 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 37305 Received: (qmail 17764 invoked from network); 4 Dec 2015 15:34:27 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,T_HDRS_LCASE, T_MANY_HDRS_LCASE autolearn=ham autolearn_force=no version=3.4.0 X-AuditID: cbfec7f4-f79026d00000418a-55-5661b280e169 Date: Fri, 04 Dec 2015 15:34:21 +0000 From: Peter Stephenson To: Zsh Hackers' List Subject: PATCH: Ghastly typeset -p array hack finally bites the dust Message-id: <20151204153421.5771f9ce@pwslap01u.europe.root.pri> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBLMWRmVeSWpSXmKPExsVy+t/xy7oNmxLDDL4tl7c42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGVM2vmQsmCFVsf5uG1MD4zKRLkZODgkBE4lNMz8zQ9hiEhfu rWfrYuTiEBJYyiix6d5UJghnBpPEtdUrWSGc04wS5zsPM0I4ZxglNv7+zwTSzyKgKvFp/3dW EJtNwFBi6qbZQEUcHCIC2hLtH8VAwsICLhLP9+xhBLF5Bewl7q3cxwJi8wvoS1z9+4kJ4gx7 iZlXzkDVCEr8mHwPrIZZQEti87YmVghbXmLzmrdgZwsJqEvcuLubfQKj4CwkLbOQtMxC0rKA kXkVo2hqaXJBcVJ6rqFecWJucWleul5yfu4mRkh4ftnBuPiY1SFGAQ5GJR5ehk0JYUKsiWXF lbmHGCU4mJVEeJllEsOEeFMSK6tSi/Lji0pzUosPMUpzsCiJ887d9T5ESCA9sSQ1OzW1ILUI JsvEwSnVwDipceOF69//+LAdcDMvD7+QuMdH31cve5PhOt99CrPeuYrelc6/FvDQ4Ha24c1m Zf7LkmyLLK+6pAplbpmoUX3k/Y+dz5Uc7ctcZjmn7r/vml344ErwCwWFHr7Iw1ME5wafcr1X ZlxYz1rJXDxJp5AjsJdBxsBEZsHF2VueKIVcNmxn7Bd7qsRSnJFoqMVcVJwIAKKGKFBLAgAA diff --git a/Src/params.c b/Src/params.c index aed72d4..8cab969 100644 --- a/Src/params.c +++ b/Src/params.c @@ -5182,9 +5182,6 @@ printparamvalue(Param p, int printflags) } if (printflags & PRINT_KV_PAIR) putchar(' '); - else if ((printflags & PRINT_TYPESET) && - (PM_TYPE(p->node.flags) == PM_ARRAY || PM_TYPE(p->node.flags) == PM_HASHED)) - printf("%s=", p->node.nam); else putchar('='); @@ -5255,7 +5252,6 @@ mod_export void printparamnode(HashNode hn, int printflags) { Param p = (Param) hn; - int array_typeset; if (p->node.flags & PM_UNSET) { if (isset(POSIXBUILTINS) && (p->node.flags & PM_READONLY) && @@ -5280,28 +5276,8 @@ printparamnode(HashNode hn, int printflags) */ return; } - /* - * Printing the value of array: this needs to be on - * a separate line so more care is required. - */ - array_typeset = (PM_TYPE(p->node.flags) == PM_ARRAY || - PM_TYPE(p->node.flags) == PM_HASHED) && - !(printflags & PRINT_NAMEONLY); - if (array_typeset && (p->node.flags & PM_READONLY)) { - /* - * We need to create the array before making it - * readonly. - */ - printf("typeset -a "); - zputs(p->node.nam, stdout); - putchar('\n'); - printparamvalue(p, printflags); - printflags |= PRINT_NAMEONLY; - } printf("typeset "); } - else - array_typeset = 0; /* Print the attributes of the parameter */ if (printflags & (PRINT_TYPE|PRINT_TYPESET)) { @@ -5349,8 +5325,6 @@ printparamnode(HashNode hn, int printflags) } else { quotedzputs(p->node.nam, stdout); - if (array_typeset) - putchar('\n'); printparamvalue(p, printflags); } } diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst index fc8b3e4..7d65cc8 100644 --- a/Test/B02typeset.ztst +++ b/Test/B02typeset.ztst @@ -454,8 +454,7 @@ fn() { typeset -p array nonexistent; } fn 1:declare -p shouldn't create scoped values ->typeset -a array ->array=( foo bar ) +>typeset -a array=( foo bar ) ?fn:typeset: no such variable: nonexistent unsetopt typesetsilent @@ -508,11 +507,8 @@ typeset -pm 'a[12]' typeset -pm 'r[12]' 0:readonly -p output ->typeset -a a1 ->a1=( one two ) ->typeset -ar a1 ->typeset -a a2 ->a2=( three four ) +>typeset -ar a1=( one two ) +>typeset -a a2=( three four ) >typeset -r r1=yes >typeset -r r2=no @@ -707,8 +703,6 @@ fn print $array 0:setting empty array in typeset ->typeset -a array ->array=( '' two '' four ) ->typeset -a array ->array=( one '' three ) +>typeset -a array=( '' two '' four ) +>typeset -a array=( one '' three ) >no really nothing here diff --git a/Test/V10private.ztst b/Test/V10private.ztst index 513a3c4..320e357 100644 --- a/Test/V10private.ztst +++ b/Test/V10private.ztst @@ -127,12 +127,9 @@ outer print ${(kv)hash_test} 0:private hides value from surrounding scope in nested scope ->typeset -a hash_test ->hash_test=( top level ) ->typeset -A hash_test ->hash_test=( in function ) ->typeset -a hash_test ->hash_test=( top level ) +>typeset -a hash_test=( top level ) +>typeset -A hash_test=( in function ) +>typeset -a hash_test=( top level ) >array-local top level >top level F:note "typeset" rather than "private" in output from outer