From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12358 invoked from network); 16 Apr 2001 16:07:18 -0000 Received: from sunsite.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 16 Apr 2001 16:07:18 -0000 Received: (qmail 24389 invoked by alias); 16 Apr 2001 16:07:12 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 13993 Received: (qmail 24376 invoked from network); 16 Apr 2001 16:07:11 -0000 From: "Bart Schaefer" Message-Id: <1010416160604.ZM12205@candle.brasslantern.com> Date: Mon, 16 Apr 2001 16:06:04 +0000 References: <20010414202410.A10021@dman.com> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.dk Subject: (Fwd) Re: requests MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii My apologies if this ends up appearing twice -- I sent it Saturday night but it still hasn't come through the archives. In the interim since the text below was written, I've posted a patch that includes a fix for the #3 bug. --- Forwarded mail from ("Bart Schaefer") From: "Bart Schaefer" Date: Sun, 15 Apr 2001 03:28:58 +0000 To: zsh-workers@sunsite.dk Subject: Re: requests Cc: 92780-forwarded@bugs.debian.org, mpol@charybda.icm.edu.pl The timing of this is interesting, as I've just spent the entire day fooling with SourceForge bug #104052 (without making much headway). On Apr 14, 8:24pm, Clint Adams wrote: } Subject: requests } } Michal, how do you want ${param[(r)$anotherparam]} to behave, if not } treating $anotherparam as a pattern? He wants expansion to behave as it would outside subscript [ ]; that is, one must use $~param to get file globbing to happen, so he'd also like that rule to apply within subscripts. It's fairly difficult, for example, to match a literal "*" using subscription. } 1. in ${param[(r)$anotherparam]} the result of $anotherparam } is always treated as a pattern, it would be nice if one could use } $~anotherparam for this. The "reason" for this behavior is that the stuff inside the [ ] is, supposedly, parsed as if double-quoted. So in order to treat as a pattern those strings that do NOT result from a parameter expansion, the (r) has to imply the same sort of tokenization as $~anotherparam. E.g. in $param[(r)foo*$bar], foo* has to first be parsed as if quoted (otherwise it'd be a file glob!) and then tokenized, so the same happens to $bar. Internally, the expansion of $anotherparam is done independently of the subscripting flag (r), which later tokenizes the fully-expanded subscript. One can get the desired effect by using ${param[(r)${(q)anotherparam}]}, but (another inconsistency) this works for arrays but fails for string subscription on scalars. That's clearly a bug. } 2. ${(B)param#pattern} } gives 1 when there's no match -- could give 0 or 1+$#param like } ${param[(i)pattern]} } the same for (E) and {...%...} This is a known inconsistency (there's even a comment about it in the Tests/*parameter.ztst file). It's been left unchanged for backwards compatibility, though it's not clear whether its use is widespread enough that it would cause an outcry were it changed. Probably it could be changed because nobody is using it; in fact, I'm inclined to wonder what Michal is doing that caused him even to notice. } 3. ${param[(i)pattern]} behaves differently for scalars and for arrays } when there is no match. For scalars returns 0, for arrays the index of } last element + 1. I think that one's just an implementation oversight; both forward and reverse subscripting of scalars fall through to the same return value when the pattern isn't found. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net ---End of forwarded mail from ("Bart Schaefer") -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net