From owner-svn-src-head@FreeBSD.ORG Tue Dec 28 13:28:24 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8D553106566B; Tue, 28 Dec 2010 13:28:24 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7C3458FC0C; Tue, 28 Dec 2010 13:28:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oBSDSOgI063232; Tue, 28 Dec 2010 13:28:24 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oBSDSOUo063229; Tue, 28 Dec 2010 13:28:24 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201012281328.oBSDSOUo063229@svn.freebsd.org> From: Jilles Tjoelker Date: Tue, 28 Dec 2010 13:28:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r216761 - in head: bin/sh tools/regression/bin/sh/expansion X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Dec 2010 13:28:24 -0000 Author: jilles Date: Tue Dec 28 13:28:24 2010 New Revision: 216761 URL: http://svn.freebsd.org/changeset/base/216761 Log: sh: Make expansion errors in optimized command substitution non-fatal. Command substitutions consisting of a single simple command are executed in the main shell process but this should be invisible apart from performance and very few exceptions such as $(trap). Added: head/tools/regression/bin/sh/expansion/cmdsubst5.0 (contents, props changed) Modified: head/bin/sh/eval.c Modified: head/bin/sh/eval.c ============================================================================== --- head/bin/sh/eval.c Tue Dec 28 12:37:57 2010 (r216760) +++ head/bin/sh/eval.c Tue Dec 28 13:28:24 2010 (r216761) @@ -578,6 +578,8 @@ evalbackcmd(union node *n, struct backcm int pip[2]; struct job *jp; struct stackmark smark; /* unnecessary */ + struct jmploc jmploc; + struct jmploc *savehandler; setstackmark(&smark); result->fd = -1; @@ -590,7 +592,19 @@ evalbackcmd(union node *n, struct backcm } if (n->type == NCMD) { exitstatus = oexitstatus; - evalcommand(n, EV_BACKCMD, result); + savehandler = handler; + if (setjmp(jmploc.loc)) { + if (exception == EXERROR || exception == EXEXEC) + exitstatus = 2; + else if (exception != 0) { + handler = savehandler; + longjmp(handler->loc, 1); + } + } else { + handler = &jmploc; + evalcommand(n, EV_BACKCMD, result); + } + handler = savehandler; } else { exitstatus = 0; if (pipe(pip) < 0) Added: head/tools/regression/bin/sh/expansion/cmdsubst5.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/expansion/cmdsubst5.0 Tue Dec 28 13:28:24 2010 (r216761) @@ -0,0 +1,5 @@ +# $FreeBSD$ + +unset v +exec 2>/dev/null +! y=$(: ${v?})