Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 4 May 2011 22:12:22 +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: r221463 - in head: bin/sh tools/regression/bin/sh/expansion
Message-ID:  <201105042212.p44MCMQa069440@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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" ]



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105042212.p44MCMQa069440>