From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org (Zsh hackers list)
Subject: PATCH: (z) splitting with double parenthesis
Date: Sat, 18 Dec 2010 23:21:18 +0000 [thread overview]
Message-ID: <10922.1292714478@pws-pc.ntlworld.com> (raw)
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 <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
reply other threads:[~2010-12-18 23:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=10922.1292714478@pws-pc.ntlworld.com \
--to=p.w.stephenson@ntlworld.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).