Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: let unset array element remove compatible with bash
On Tue, 21 Feb 2012 21:01:06 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Feb 22, 3:28am, Daniel Lin wrote:
> }
> } Can any developer consider to enhance zsh's function like "unset var[2]"?
>
> Hmm, what's the reason NOT to do this? I can think of one: "unset var[9]"
> might cause elements 2 through 8 to spring into existence, which is surely
> counter-intuitive ... but of course the same thing happens with var[9]=().
It should work, but it's not quite trivial:
$ array=(one three)
$ echo ${#array[*]}
2
$ unset 'array[8]'
$ echo ${#array[*]}
2
So it's not simply a case of unconditionally deleting an element. I
think you need to check the element is present in the first place.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK
Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
Messages sorted by:
Reverse Date,
Date,
Thread,
Author