From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6664 invoked by alias); 2 Oct 2012 12:39:53 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17304 Received: (qmail 23820 invoked from network); 2 Oct 2012 12:39:50 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) 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.2 Received-SPF: none (ns1.primenet.com.au: domain at csr.com does not designate permitted sender hosts) Date: Tue, 2 Oct 2012 12:57:18 +0100 From: Peter Stephenson To: "zsh-users@zsh.org" Subject: Re: Bug / error in manpage. Message-ID: <20121002125718.3ba26743@pwslap01u.europe.root.pri> In-Reply-To: References: Organization: Cambridge Silicon Radio X-Mailer: Claws Mail 3.7.9 (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.99.10.25] X-Scanned-By: MailControl 9446.0 (www.mailcontrol.com) on 10.68.0.121 (By the way, my work email is about to change, so if you're emailing me directly, which isn't usually necessary for zsh discussions, use my home email, p.w.stephenson@ntlworld.com. You should get a useful bounce message when it does change, however.) On Mon, 1 Oct 2012 18:08:36 +0000 Larry Schrof wrote: > The man page for subscripting flags is incorrect. Here is the excerpt: > > The flags s, n and b take an argument; the delimiter is shown below as > `:', but any character, or the matching pairs `(...)', `{...}', > `[...]', or `<...>', may be used. > > The '< >' brackets do not work as separators: > zsh% print $string[(ws<:>)2] > zsh: parse error near `)' > zsh% I don't think there's any reason this shouldn't be made to work; there's currently no check to make the square bracket context special for angle brackets, except if you used braces in the parameter substitution. The change also makes things like this work: [[ '' = [<>]*[<>] ]] I interpret that as a good thing. Angle brackets only need to do special things when used as redirection operators and (to a more limited extent, since they're then part of a string) numeric glob ranges. Index: Src/lex.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/lex.c,v retrieving revision 1.70 diff -p -u -r1.70 lex.c --- Src/lex.c 8 Dec 2011 19:42:07 -0000 1.70 +++ Src/lex.c 2 Oct 2012 11:45:19 -0000 @@ -1218,7 +1218,7 @@ gettokstr(int c, int sub) c = Comma; break; case LX2_OUTANG: - if (in_brace_param || sub) + if (in_brace_param || sub || brct) break; e = hgetc(); if (e != '(') { @@ -1255,7 +1255,7 @@ gettokstr(int c, int sub) break; } lexstop = 0; - if (in_brace_param || sub) + if (in_brace_param || sub || brct) break; goto brk; case LX2_EQUALS: Index: Test/D06subscript.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/D06subscript.ztst,v retrieving revision 1.13 diff -p -u -r1.13 D06subscript.ztst --- Test/D06subscript.ztst 31 Jul 2008 13:53:28 -0000 1.13 +++ Test/D06subscript.ztst 2 Oct 2012 11:45:20 -0000 @@ -249,3 +249,23 @@ string[0]=! 1:Can't set only element zero of string ?(eval):1: string: assignment to invalid subscript range + + string="Life,+like+a+dome+of+many-colour'd+glass" + for delims in "()" "{}" "[]" "<>"; do + eval 'print ${string[(ws'$delims[1]'+'$delims[2]')2]}' + eval 'print $string[(ws'$delims[1]'+'$delims[2]')3]' + eval 'print "$string[(ws'$delims[1]'+'$delims[2]')4]"' + done +0:Check matched delimiters in subscripts +>like +>a +>dome +>like +>a +>dome +>like +>a +>dome +>like +>a +>dome -- 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 More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog