From owner-svn-src-head@FreeBSD.ORG Wed May 4 22:12:22 2011 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 CE6701065676; Wed, 4 May 2011 22:12:22 +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 BACD88FC12; Wed, 4 May 2011 22:12:22 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p44MCM6D069443; Wed, 4 May 2011 22:12:22 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p44MCMQa069440; Wed, 4 May 2011 22:12:22 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201105042212.p44MCMQa069440@svn.freebsd.org> From: Jilles Tjoelker Date: Wed, 4 May 2011 22:12:22 +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: r221463 - 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: Wed, 04 May 2011 22:12:22 -0000 Author: jilles Date: Wed May 4 22:12:22 2011 New Revision: 221463 URL: http://svn.freebsd.org/changeset/base/221463 Log: sh: Apply set -u to variables in arithmetic. Note that this only applies to variables that are actually used. Things like (0 && unsetvar) do not cause an error. Exp-run done by: pav (with some other sh(1) changes) Added: head/tools/regression/bin/sh/expansion/set-u3.0 (contents, props changed) Modified: head/bin/sh/arith_yacc.c Modified: head/bin/sh/arith_yacc.c ============================================================================== --- head/bin/sh/arith_yacc.c Wed May 4 22:02:33 2011 (r221462) +++ head/bin/sh/arith_yacc.c Wed May 4 22:12:22 2011 (r221463) @@ -97,6 +97,8 @@ static arith_t arith_lookupvarint(char * arith_t result; str = lookupvar(varname); + if (uflag && str == NULL) + yyerror("variable not set"); if (str == NULL || *str == '\0') str = "0"; errno = 0; Added: head/tools/regression/bin/sh/expansion/set-u3.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/expansion/set-u3.0 Wed May 4 22:12:22 2011 (r221463) @@ -0,0 +1,6 @@ +# $FreeBSD$ + +set -u +unset x +v=$( (eval ': $((x))') 2>&1 >/dev/null) +[ $? -ne 0 ] && [ -n "$v" ]