Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Typeset with array
- X-seq: zsh-workers 35532
- From: Oliver Kiddle <okiddle@xxxxxxxxxxx>
- To: Zsh Hackers' List <zsh-workers@xxxxxxx>
- Subject: Re: Typeset with array
- Date: Fri, 19 Jun 2015 19:36:26 +0200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1434735387; bh=vxQLYVLrkJx1H8xVSLOVLgLgpe4GyrQvWapPgwe+EsM=; h=In-reply-to:From:References:To:Subject:Date:From:Subject; b=H7fbRBTJg0la+7gGMQJhhMx7cEeUa5vptqKMGp6CdpazVAd0YPdCIodc4H+mfHzgHaq4LQtzIcamCyy1I6XLREh/XShtHbtQ/LaUPS/vyuuSg0V/k6bmgP7aMzPun4DdM3ezPNfm5nAGuVk24vecAX6LzI7UpnMOyM0KfpZyJMRdy2RdqqNEzhvkhOJwr1NIAU0mna70HOrZ5xY1eIYBGdIHvlQ7ogPheN+skFPenyaLXj3qmlkix4qKdjr8Ku346ufgwPROG1nmRoLEHchdzW7o281zXKXNw6tfJFLYzfIIGR5r3T9U5/L1rYiqzMpe4Q1LShCO3Ws3nqJf8mjjPA==
- In-reply-to: <20150619123930.2688d9e3@pwslap01u.europe.root.pri>
- 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: <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>
Peter wrote:
> Here's where the Cunning Plan comes in: the spcial assignment behaviour
Firstly, this looks fantastic. Much of my initial basic testing seems to
already be working.
I'll mention some of the things I tried. Just in case there's something
you hadn't thought of. Some combinations aren't especially sane but
might want an error message.
local -a foo=one
So scope needs to be handled first and array conversion later.
Similarly: typeset -i foo=(23)
I did something like the following in _git recently. It works
arr=( one two three )
local $arr
There is also
local $^arr=foo
and
local $^^arr=foo
The nearest in bash would be:
declare {a,b,c}=foo
which works, but not:
declare {a,b,c}=(one two)
Bash apparently lets you use += with declare but it seems to be
meaningless because it is not using the value from the outer scope:
$ foo=hello
$ function foo {
> local foo+=bye
> echo $foo
> }
$ foo
bye
$ echo $foo
hello
Ksh doesn't allow it. Printing an error in this case seems best which is
what you have: typeset: not valid in this context: var+
Bash allows array element assignments:
typeset var[4]=hello
Zsh now prints "can't create local array elements"
Including when not in a function.
That could also be extended to something like var[2,7]=(1 2)
This is perhaps jumping ahead a bit but for completion, it seems we now
get -command- context after typeset. As long as -var- context is applied
inside the actual contexts, having -command- context otherwise for
typeset would probably work fine.
It seems that it is already possible to have assignments after nocorrect
so there may already be handling for this situation by copying whatever
is done for nocorrect.
Is there a reason why noglob can't precede assignments. That could be
useful.
Oliver
Messages sorted by:
Reverse Date,
Date,
Thread,
Author