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

Re: set -A



On 6 Feb, you wrote:
> I think this is a bug in all versions, but if there's some reason
> the behaviour could be considered correct, it'd be nice if it at
> least worked like ksh in emulation mode.  I recently had some trouble
> getting a ksh script to work properly in zsh, as illustrated by:
> 
> unset arr
> set -A arr "${arr[@]}" first
> [ ${#arr[@]} = 2 ] && echo "arr[0]='${arr[0]}' arr[1]='${arr[1]}'"
> 
> Note the null entry on the start of the array.  I believe the above
> should work as in ksh, and consistently with positional parameters,
> like this:

I'm inclined to agree that this is wrong. It would seem more logical to
me for an unset variable to be interpreted as an empty array when
retrieved in array context. A similar thing which I find annoying is
that local defines parameters to be scalar by default instead of
leaving their type undefined causing similar empty element problems.

I've been aware of this for some while and had intended to change it if
I ever have time to finish work on the parameter code. Would changing
it break much? It would improve bash/ksh compatibility.

Oliver

This e-mail and any attachment is for authorised use by the intended recipient(s) only.  It may contain proprietary material, confidential information and/or be subject to legal privilege.  It should not be copied, disclosed to, retained or used by, any other party.  If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender.  Thank you.



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