From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20874 invoked by alias); 18 Dec 2010 23:51:48 -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: 28537 Received: (qmail 12455 invoked from network); 18 Dec 2010 23:51:45 -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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.1 Received-SPF: pass (ns1.primenet.com.au: SPF record at ntlworld.com designates 81.103.221.58 as permitted sender) From: Peter Stephenson To: zsh-workers@zsh.org (Zsh hackers list) Subject: PATCH: (z) splitting with double parenthesis X-Mailer: MH-E 8.2; nmh 1.3; GNU Emacs 23.2.1 Date: Sat, 18 Dec 2010 23:21:18 +0000 Message-ID: <10922.1292714478@pws-pc.ntlworld.com> X-Cloudmark-Analysis: v=1.1 cv=X0sWjjQ37bMP4yB/pNNinY3VxVB2n/hmdAjhihaCFGs= c=1 sm=0 a=LmhFDSL9FyEA:10 a=NLZqzBF-AAAA:8 a=unFTt8N4IyuxCIWuuYcA:9 a=yzycERqsWtBKN31eg4MA:7 a=nZ3buUj34a65mLX_PNjPYC6xG5EA:4 a=_dQi-Dcv4p4A:10 a=HpAAvcLHHh0Zw7uRqdWCyQ==:117 Happens when a introductory double parenthesis turns out to want to be a subshell substitution rather than a math substitution. % foo='((0.25542 * 60) - 15)*60' % print -l ${(z)foo} 0.25542 * 60 ( 0.25542 * 60 ) - 15 ) *60 This only applies to command position since otherwise parentheses don't cause a new word... hmm, I think (Z) could do with an option to say don't treat the first word as a command word, but that can wait. You can work around it with foo=": $foo" split=(${${(z)foo}[2,-1]}) Index: Src/lex.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/lex.c,v retrieving revision 1.62 diff -p -u -r1.62 lex.c --- Src/lex.c 14 Dec 2010 10:40:42 -0000 1.62 +++ Src/lex.c 18 Dec 2010 23:13:43 -0000 @@ -885,6 +885,11 @@ gettok(void) return DINPAR; case 0: + /* + * Not math, so we don't return the contents + * as a string in this case. + */ + tokstr = NULL; return INPAR; default: Index: Test/D04parameter.ztst =================================================================== RCS file: /cvsroot/zsh/zsh/Test/D04parameter.ztst,v retrieving revision 1.51 diff -p -u -r1.51 D04parameter.ztst --- Test/D04parameter.ztst 15 Dec 2010 04:05:50 -0000 1.51 +++ Test/D04parameter.ztst 18 Dec 2010 23:13:43 -0000 @@ -393,6 +393,7 @@ 'foo=(1 2 3)' '(( 3 + 1 == 8 / 2 ))' 'for (( i = 1 ; i < 10 ; i++ ))' + '((0.25542 * 60) - 15)*60' ) for string in $strings; do array=(${(z)string}) @@ -416,6 +417,19 @@ >4:i < 10 ;: >5:i++ : >6:)): +# This one needs resolving between a math expression and +# a command, which causes interesting effects internally. +>1:(: +>2:(: +>3:0.25542: +>4:*: +>5:60: +>6:): +>7:-: +>8:15: +>9:): +>10:*60: + line=$'A line with # someone\'s comment\nanother line # (1 more\nanother one' print "*** Normal ***" -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/