From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26241 invoked from network); 31 Oct 2006 17:09:06 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.7 (2006-10-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.7 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 31 Oct 2006 17:09:06 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 25103 invoked from network); 31 Oct 2006 17:09:00 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 31 Oct 2006 17:09:00 -0000 Received: (qmail 2351 invoked by alias); 31 Oct 2006 17:08:52 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22937 Received: (qmail 2342 invoked from network); 31 Oct 2006 17:08:50 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 31 Oct 2006 17:08:50 -0000 Received: (qmail 24480 invoked from network); 31 Oct 2006 17:08:50 -0000 Received: from cluster-d.mailcontrol.com (217.69.20.190) by a.mx.sunsite.dk with SMTP; 31 Oct 2006 17:08:44 -0000 Received: from cameurexb01.EUROPE.ROOT.PRI ([62.189.241.200]) by rly22d.srv.mailcontrol.com (MailControl) with ESMTP id k9VH6bd3032318 for ; Tue, 31 Oct 2006 17:08:41 GMT Received: from news01.csr.com ([10.103.143.38]) by cameurexb01.EUROPE.ROOT.PRI with Microsoft SMTPSVC(6.0.3790.1830); Tue, 31 Oct 2006 17:08:30 +0000 Received: from news01.csr.com (localhost.localdomain [127.0.0.1]) by news01.csr.com (8.13.7/8.13.4) with ESMTP id k9VH8UUM025698 for ; Tue, 31 Oct 2006 17:08:30 GMT Received: from csr.com (pws@localhost) by news01.csr.com (8.13.7/8.13.7/Submit) with ESMTP id k9VH8UX8025695 for ; Tue, 31 Oct 2006 17:08:30 GMT Message-Id: <200610311708.k9VH8UX8025695@news01.csr.com> X-Authentication-Warning: news01.csr.com: pws owned process doing -bs To: zsh-workers@sunsite.dk Subject: Re: Prepend/append to the members of a list In-reply-to: <061031083123.ZM10976@torch.brasslantern.com> References: <20061030170919.GA9507@alea.gnuu.de> <200610311452.k9VEqKNI013158@news01.csr.com> <061031083123.ZM10976@torch.brasslantern.com> Comments: In-reply-to Bart Schaefer message dated "Tue, 31 Oct 2006 08:31:23 -0800." Date: Tue, 31 Oct 2006 17:08:30 +0000 From: Peter Stephenson X-OriginalArrivalTime: 31 Oct 2006 17:08:30.0651 (UTC) FILETIME=[307D90B0:01C6FD0F] Content-Type: text/plain MIME-Version: 1.0 X-Scanned-By: MailControl A-07-06-65 (www.mailcontrol.com) on 10.68.0.132 Bart Schaefer wrote: > On Oct 31, 2:52pm, Peter Stephenson wrote: > } > } +When tt(HIST_SUBST_PATTERN) is set, var(l) may start with a tt(#) > } +to indicate that the pattern must match at the start of the string > } +to be substituted, and a tt(%) may appear at the start or after an tt(#) > } +to indicate that the pattern must match at the end of the string > } +to be substituted. > > The doc in parameter expansion says > > The PATTERN may begin with a `#', in which case the PATTERN must > match at the start of the string, or `%', in which case it must > match at the end of the string. > > Should that doc also say that #% is a legal pattern meaning "anchor > the match at both ends of the string"? With the current code, no, because that's not supported. I suppose it would be sensible to add that for compatibility---although it does change the syntax in the not particularly likely but by no means impossible case that you're substituting a % at the head of a string, so I'm not so sure. I didn't add it before because I assumed we already had other ways of doing it; now I come to think of it, I can't actually think of one that doesn't involve the use of extended globbing (i.e. (#s) or (#e)). :# removes a complete match, but doesn't replace it. None of the flags that modify matching tell it to force a complete match. So maybe it could do with adding. Any strong views? However, I screwed up: it doesn't work even for :s/#%.../.../ because I'd forgotten there was no way to tell the underlying pattern substitution code to anchor at both ends. So it accepts the syntax but actually anchors only at the tail. That turns out to be easy to fix, and I'll do it in whatever I commit. Another annoyance, again to do with the horrors of tokenization when you do things out of the usual order of parsing, is that you need to quote % and # with two backslashes. I'll document this. It's for basically the same reason that in glob qualifiers you need an extra layer of quotes round parameters; I'm not sure I can deal with both problems consistently and it's probably best to leave this for consistency. -- Peter Stephenson Software Engineer CSR PLC, Churchill House, Cambridge Business Park, Cowley Road Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070 To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php