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

Re: Unsetting Array

"Jerry Rocteur" wrote:
> I'm using ZSH_VERION 4.2.6 on Redhat 5 to test some Korn shell scripts.
> Note that /usr/bin/ksh is a link to /bin/zsh
> I am unsetting an array like this unset variable[$i] and get
> What is the correct way to unset an array element.

You can't strictly *unset* an element to an array.  In zsh, an array is
always a set of strings that has a particular length.  So what you can
do is limited to changing the length of the array or setting an element
of the array to be an empty string.  The latter is probably nearest to
what you want, but (in places where it makes a difference) the shell
will always treat the empty element as a string with zero length, not as
an unset parameter.  The syntax for that is


Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070

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