Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: let unset array element remove compatible with bash

On Wed, 22 Feb 2012 09:28:27 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Feb 22,  9:52am, Peter Stephenson wrote:
> }
> } 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.
> Is there a straightforward way to do that?  The code in subst.c that
> handles ${+var[x]} is rather convoluted, and every combination of
> getvalue()/fetchvalue() that I've tried always returns non-NULL for
> subscripted expressions.

At this level, I'd have thought it was good enough to test the length of
the array directly.  However, you can only do that after you've
evaluated the subscript, so it probably needs some poking down into
params.c first.

Presumably if you're trying to unset an element of the array, retrieving
it isn't likely to be difficult.
> Gaah.

Didn't I say that?

Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/

Messages sorted by: Reverse Date, Date, Thread, Author