From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5863 invoked by alias); 19 Jun 2015 20:32:11 -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: 35537 Received: (qmail 17063 invoked from network); 19 Jun 2015 20:32:09 -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,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.0 X-Originating-IP: [80.3.228.158] X-Spam: 0 X-Authority: v=2.1 cv=RLtOZNW+ c=1 sm=1 tr=0 a=P+FLVI8RzFchTbbqTxIDRw==:117 a=P+FLVI8RzFchTbbqTxIDRw==:17 a=kj9zAlcOel0A:10 a=NLZqzBF-AAAA:8 a=q2GGsy2AAAAA:8 a=9OGjo4_9Tm0FixOa3XkA:9 a=CjuIK1q_8ugA:10 Date: Fri, 19 Jun 2015 21:32:04 +0100 From: Peter Stephenson To: "Zsh Hackers' List" Subject: Re: Typeset with array Message-ID: <20150619213204.4e5eb013@ntlworld.com> In-Reply-To: <150619090904.ZM4132@torch.brasslantern.com> References: <5578996E.3080700@thequod.de> <150610191427.ZM30841@torch.brasslantern.com> <5579C247.1060800@thequod.de> <150611183639.ZM32247@torch.brasslantern.com> <20150612094237.338f79d5@pwslap01u.europe.root.pri> <20150619123930.2688d9e3@pwslap01u.europe.root.pri> <150619090904.ZM4132@torch.brasslantern.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Fri, 19 Jun 2015 09:09:04 -0700 Bart Schaefer wrote: > 1. It's now possible to assign both arrays and scalars in one statement. > > - what happens for typeset -a x="string" y=(word list) ?? Oliver noted this, too (most of his examples should in principle do something sensible eventually but I haven't got round to that level of detail yet). I think it doesn't matter that much if either this gets silently turned into x=("string"), or if there's an error on the x assignment, as long as we pick one and document it. > 2. We don't have a distinct syntax for associative array assignment, so > this still works only for ordinary arrays. > > - ksh of course uses h=([key] value) to assign an associative array. Well, we don't have that syntax, but this should work: typeset -A hash=(bob robert bill william) but doesn't because of a bug fixed below. If you're playing along at home --- this is exclusive to the typeset-array branch. pws diff --git a/Src/builtin.c b/Src/builtin.c index b34669f..6cccf53 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -1998,7 +1998,7 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func), /* attempting a type conversion, or making a tied colonarray? */ tc = 0; - if (ASG_ARRAYP(asg)) + if (ASG_ARRAYP(asg) && PM_TYPE(on) == PM_SCALAR) on |= PM_ARRAY; if (usepm && ASG_ARRAYP(asg) && newspecial == NS_NONE && PM_TYPE(pm->node.flags) != PM_ARRAY &&