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

Re: PATCH Re: let unset array element remove compatible with bash



On Sun, 01 Jul 2012 09:53:54 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> So the patch below makes
> 
>     noglob unset foo[x]
> 
> work properly.  If x is an existing index (or valid slice), it is cut
> from the array as if by foo[x]=().

Do you mean that?  That's not how bash works, it doesn't cut the
element, just remove the value at that index (ignore the offset-zero
vs. offset-one difference, of course):

[pws@pws-pc tmp]$ foo=(one two three)
[pws@pws-pc tmp]$ echo ${foo[*]}
one two three
[pws@pws-pc tmp]$ echo ${foo[0]}
one
[pws@pws-pc tmp]$ echo ${foo[2]}
three
[pws@pws-pc tmp]$ unset 'foo[1]'
[pws@pws-pc tmp]$ echo ${foo[1]}

[pws@pws-pc tmp]$ echo ${foo[2]}
three

-- 
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