From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9447 invoked by alias); 21 Mar 2011 11:06:07 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 28936 Received: (qmail 27770 invoked from network); 21 Mar 2011 11:06:04 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS autolearn=ham version=3.3.1 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Mon, 21 Mar 2011 10:15:55 +0000 From: Peter Stephenson To: Subject: Re: bug in ${##} expansion Message-ID: <20110321101555.690125cd@pwslap01u.europe.root.pri> In-Reply-To: <20110311200437.18b5cad4@pws-pc.ntlworld.com> References: <4D7A72E8.5070909@redhat.com> <20110311200437.18b5cad4@pws-pc.ntlworld.com> Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.8 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.103.11.49] X-Scanned-By: MailControl A_10_80_00 (www.mailcontrol.com) on 10.68.0.159 On Fri, 11 Mar 2011 20:04:37 +0000 Peter Stephenson wrote: > On Fri, 11 Mar 2011 12:07:20 -0700 > Eric Blake wrote: > > POSIX requires ${#parameter} to expand to the length of parameter > > as a string. It also requires that ${parameter#word} substitution > > have a word (that is, ${parameter#} with a missing word is a zsh > > extension). > > > > Therefore, this should output 2, not 11: > > > > zsh -c 'set 1 2 3 4 5 6 7 8 9 10 11; echo ${##}' > > It's a straightforward bug, not specific to POSIX compatibility in > this case; testing for a name after the # is a special case which > covered some special names but not others. A couple more missing. Index: Src/subst.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/subst.c,v retrieving revision 1.118 diff -p -u -r1.118 subst.c --- Src/subst.c 11 Mar 2011 21:06:00 -0000 1.118 +++ Src/subst.c 21 Mar 2011 10:13:00 -0000 @@ -2039,6 +2039,8 @@ paramsubst(LinkList l, LinkNode n, char } else if ((c == '#' || c == Pound) && (itype_end(s+1, IIDENT, 0) != s + 1 || (cc = s[1]) == '*' || cc == Star || cc == '@' + || cc == '?' || cc == Quest + || cc == '$' || cc == String || cc == Qstring || cc == '#' || cc == Pound || cc == '-' || (cc == ':' && s[2] == '-') || (isstring(cc) && (s[2] == Inbrace || s[2] == Inpar)))) { -- Peter Stephenson Software Engineer Tel: +44 (0)1223 692070 Cambridge Silicon Radio Limited Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom