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

Re: zsh array subscripting with ksh comp behaviour



# jerry.rocteur@xxxxxxxxx / 2014-08-21 15:54:45 +0200:
> I have noticed something strange, it is easy to solve but should this
> really be default behaviour, I thought I'd report it.
> 
> ] arr=(one two three)
> ] echo ${arr[0]}
> one
> ] echo ${arr[1]}
> one
> ] echo ${arr[2]}
> two
> ] echo ${arr[3]}
> three
> 
> setopt ksharrays
> 
> ] echo ${arr[0]}
> one
> ] echo ${arr[1]}
> two
> ] echo ${arr[2]}
> three
> ] echo ${arr[3]}

zshparam(1):

Array Subscripts
  Individual  elements  of  an array may be selected using a subscript.
  A subscript of the form `[exp]' selects the single element exp, where
  exp is an arithmetic expression which will be subject to  arith‐ metic
  expansion  as if it were surrounded by `$((...))'.  The elements are
  numbered beginning with 1, unless the KSH_ARRAYS option is set in
  which case they are numbered from zero.

-- 
roman



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