From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21243 invoked from network); 16 Apr 1999 07:20:56 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 16 Apr 1999 07:20:56 -0000 Received: (qmail 24708 invoked by alias); 16 Apr 1999 07:20:26 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6045 Received: (qmail 24699 invoked from network); 16 Apr 1999 07:20:20 -0000 From: "Bart Schaefer" Message-Id: <990416001836.ZM13152@candle.brasslantern.com> Date: Fri, 16 Apr 1999 00:18:36 -0700 X-Mailer: Z-Mail (4.0b.820 20aug96) To: zsh-workers@sunsite.auc.dk Subject: Singleton arrays treated as scalars MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii I wrote: } On Apr 15, 2:08pm, Sven Wischnowsky wrote: } } Subject: Re: BUG: zsh-3.1.5-pws-14: parameter expansion not working proper } } } } Now, we could make the multsub() save (and at the end restore) the } } value of, say `static int mult_isarr'. It then sets it to zero and } } calls paramsubst() (via prefork(), as usual). At the end of } } paramsubst() we set `mult_isarr = isarr'. } } I actually tried this last night -- although I had paramsubst() set the } static to 0 on the way in; multsub() just saved and restored it -- and } it worked for some cases but not others, so I decided I was missing a } subtlety somewhere and threw it out. I tried this again and got much better results for two-or-more element arrays, but singleton arrays were still getting subscripted as scalars. Investigation led me to this fragment of paramsubst(): if (isarr > 0 && !plan9 && (!aval || !aval[0])) { val = dupstring(""); isarr = 0; } else if (isarr && aval && aval[0] && !aval[1]) { val = aval[0]; isarr = 0; } Well, look at that. If we have a singleton array, make it into a scalar. This doesn't have anything to do with multsub() at all! Does anybody remember why this code is here? What part of the world is going to come crashing down if that "else if" clause gets deleted? -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com