Date: Tue, 28 Dec 2010 13:28:24 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r216761 - in head: bin/sh tools/regression/bin/sh/expansion Message-ID: <201012281328.oBSDSOUo063229@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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?})
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201012281328.oBSDSOUo063229>