From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20120 invoked by alias); 17 Aug 2011 19:28:15 -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: 29703 Received: (qmail 10093 invoked from network); 17 Aug 2011 19:28:03 -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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received-SPF: neutral (ns1.primenet.com.au: 74.125.82.171 is neither permitted nor denied by SPF record at ntlworld.com) X-ProxyUser-IP: 86.27.188.118 Date: Wed, 17 Aug 2011 20:22:32 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: Zsh segfault with process substitution Message-ID: <20110817202232.437f23f1@pws-pc.ntlworld.com> In-Reply-To: <20110817182801.GD1382@aspen.teratorn.org> References: <20110817182801.GD1382@aspen.teratorn.org> X-Mailer: Claws Mail 3.7.9 (GTK+ 2.24.4; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Wed, 17 Aug 2011 18:28:02 +0000 "Eric P. Mangold" 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 Web page now at http://homepage.ntlworld.com/p.w.stephenson/