Array Syntax Notes

Array elements are numbered starting with 1. To start the numbering from 0 (which is more intuitive for some), turn on the zsh option KSH_ARRAYS.

(Note that setting this option has a couple of other implications you should be aware of - see other items on this page.)


The subscripts [@] and * behave almost identically, except for one subtle difference you should be aware of. It arises when the subscripts are used within double quotes:

$meat[@] will return "$meat[1]" "$meat[2]" ... "$meat[n]"

where as

$meat[*] will return "$meat[1] $meat[2] ... $meat[n]"


If the KSH_ARRAYS option is set, subscripts MUST be included with the array name inside of curly braces.
Note that you should NOT use the $ on the left hand side of the assignment.