From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22606 invoked by alias); 21 Aug 2014 14:54:12 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19029 Received: (qmail 13509 invoked from network); 21 Aug 2014 14:54:10 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Date: Thu, 21 Aug 2014 16:47:10 +0200 From: Roman Neuhauser To: Jerry Rocteur Cc: zsh-users@zsh.org Subject: Re: zsh array subscripting with ksh comp behaviour Message-ID: <20140821144710.GF4075@isis.sigpipe.cz> References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) # jerry.rocteur@gmail.com / 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