From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: Zsh segfault with process substitution
Date: Wed, 17 Aug 2011 20:22:32 +0100 [thread overview]
Message-ID: <20110817202232.437f23f1@pws-pc.ntlworld.com> (raw)
In-Reply-To: <20110817182801.GD1382@aspen.teratorn.org>
On Wed, 17 Aug 2011 18:28:02 +0000
"Eric P. Mangold" <eric@teratorn.org> wrote:
> zsh: oops.
Er, indeed.
Index: Src/exec.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/exec.c,v
retrieving revision 1.202
diff -p -u -r1.202 exec.c
--- Src/exec.c 14 Aug 2011 18:34:28 -0000 1.202
+++ Src/exec.c 17 Aug 2011 19:20:07 -0000
@@ -3755,7 +3755,15 @@ parsecmd(char *cmd, char **eptr)
for (str = cmd + 2; *str && *str != Outpar; str++);
if (!*str || cmd[1] != Inpar) {
- zerr("oops.");
+ /*
+ * This can happen if the expression is being parsed
+ * inside another construct, e.g. as a value within ${..:..} etc.
+ * So print a proper error message instead of the not very
+ * useful but traditional "oops".
+ */
+ char *errstr = dupstrpfx(cmd, 2);
+ untokenize(errstr);
+ zerr("unterminated `%s...)'", errstr);
return NULL;
}
*str = '\0';
Index: Src/subst.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/subst.c,v
retrieving revision 1.127
diff -p -u -r1.127 subst.c
--- Src/subst.c 1 Jul 2011 15:23:03 -0000 1.127
+++ Src/subst.c 17 Aug 2011 19:20:07 -0000
@@ -162,6 +162,8 @@ stringsubst(LinkList list, LinkNode node
subst = getproc(str, &rest); /* <(...) or >(...) */
else
subst = getoutputfile(str, &rest); /* =(...) */
+ if (errflag)
+ return NULL;
if (!subst)
subst = "";
Index: Test/D03procsubst.ztst
===================================================================
RCS file: /cvsroot/zsh/zsh/Test/D03procsubst.ztst,v
retrieving revision 1.5
diff -p -u -r1.5 D03procsubst.ztst
--- Test/D03procsubst.ztst 13 Nov 2008 21:18:15 -0000 1.5
+++ Test/D03procsubst.ztst 17 Aug 2011 19:20:07 -0000
@@ -84,3 +84,7 @@
)
0:=(...) preceded by other stuff has no special effect
>everything,=(here is left),alone
+
+ print something=${:-=(echo 'C,D),(F,G)'}
+1: Graceful handling of bad substitution in enclosed context
+?(eval):1: unterminated `=(...)'
--
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
prev parent reply other threads:[~2011-08-17 19:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-17 18:28 Eric P. Mangold
2011-08-17 19:22 ` 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=20110817202232.437f23f1@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).