svn commit: r221463 - in head: bin/sh
tools/regression/bin/sh/expansion
Jilles Tjoelker
jilles at FreeBSD.org
Wed May 4 22:12:22 UTC 2011
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" ]
More information about the svn-src-head
mailing list