From: Peter Stephenson <Peter.Stephenson@csr.com>
To: <zsh-workers@zsh.org>
Subject: Re: let unset array element remove compatible with bash
Date: Wed, 22 Feb 2012 09:52:48 +0000 [thread overview]
Message-ID: <20120222095248.1ea8140b@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <120221210106.ZM13374@torch.brasslantern.com>
On Tue, 21 Feb 2012 21:01:06 -0800
Bart Schaefer <schaefer@brasslantern.com> 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@csr.com> 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
next prev parent reply other threads:[~2012-02-22 10:43 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CAPg-njyehwyETKY4KGdFV8u_ZwkMku-G9xVi7d7PpU9rZhdPDA@mail.gmail.com>
2012-02-22 5:01 ` Bart Schaefer
2012-02-22 9:52 ` Peter Stephenson [this message]
2012-02-22 17:28 ` Bart Schaefer
2012-02-22 20:19 ` Peter Stephenson
2012-07-01 16:53 ` PATCH " Bart Schaefer
2012-07-01 18:15 ` Peter Stephenson
2012-07-01 22:23 ` Bart Schaefer
2012-07-02 9:11 ` Peter Stephenson
2012-07-07 17:02 ` Bart Schaefer
2012-07-08 17:50 ` Peter Stephenson
2012-07-01 22:29 ` Bart Schaefer
2012-07-02 7:36 ` Bart Schaefer
2012-02-23 10:58 ` Peter Stephenson
2012-02-23 16:23 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120222095248.1ea8140b@pwslap01u.europe.root.pri \
--to=peter.stephenson@csr.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).