From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3389 invoked from network); 19 Jul 1999 00:03:24 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 19 Jul 1999 00:03:24 -0000 Received: (qmail 26471 invoked by alias); 19 Jul 1999 00:03:14 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 7186 Received: (qmail 26464 invoked from network); 19 Jul 1999 00:03:13 -0000 From: "Bart Schaefer" Message-Id: <990719000259.ZM8741@candle.brasslantern.com> Date: Mon, 19 Jul 1999 00:02:59 +0000 In-Reply-To: Comments: In reply to Tanaka Akira "string range between 1 and 0." (Jul 18, 1:14pm) References: X-Mailer: Z-Mail (5.0.0 30July97) To: Tanaka Akira , zsh-workers@sunsite.auc.dk Subject: Re: string range between 1 and 0. MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jul 18, 1:14pm, Tanaka Akira wrote: } Subject: string range between 1 and 0. } } Hi. I wondered that $var[1,0] is expanded to first character of v. [...] } Is this intentional behaviour? This is a side-effect of ksh array compatibility, believe it or not. For quite some time now, it has been the case that $x[0] == $x[1] when NOT emulating ksh. This documented in section 2.1 of the FAQ, though it does not seem to be mentioned in the actual manual. The same code is used to interpret the second value in a subscript range, so $x[0,0] == $x[1,1] == $x[0,1] == $x[1,0] unless you are using zero- based arrays as in ksh. This also means that $x[2,0] == $x[2,1] which is the empty string either way; the only interesting thing happens when the first of the range is 1. } I think that $v[1,0] should be null string as $v[2,0]. It is, when ksharrays is set ... If it weren't handled this way, then $x[anything,0] in the non-ksharrays case would have to yield an "invalid subscript" error -- the only other alternative is to treat $x[n,0] as $x[n,-1] which gives all the elements from n to the end. So, given the choices (1) leave it as is (2) treat [n,0] as [n,-1] (3) treat [n,0] as an error my own preference is for (1). -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com