zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <Peter.Stephenson@csr.com>
To: <zsh-workers@zsh.org>
Subject: Re: bug in ${##} expansion
Date: Mon, 21 Mar 2011 10:15:55 +0000	[thread overview]
Message-ID: <20110321101555.690125cd@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20110311200437.18b5cad4@pws-pc.ntlworld.com>

On Fri, 11 Mar 2011 20:04:37 +0000
Peter Stephenson <p.w.stephenson@ntlworld.com> wrote:
> On Fri, 11 Mar 2011 12:07:20 -0700
> Eric Blake <eblake@redhat.com> 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 <pws@csr.com>            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


      reply	other threads:[~2011-03-21 11:06 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-11 19:07 Eric Blake
2011-03-11 20:04 ` Peter Stephenson
2011-03-21 10:15   ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110321101555.690125cd@pwslap01u.europe.root.pri \
    --to=peter.stephenson@csr.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).