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)
This commit is contained in:
parent
5a816b92a3
commit
3937fc9c26
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=221463
@ -97,6 +97,8 @@ static arith_t arith_lookupvarint(char *varname)
|
|||||||
arith_t result;
|
arith_t result;
|
||||||
|
|
||||||
str = lookupvar(varname);
|
str = lookupvar(varname);
|
||||||
|
if (uflag && str == NULL)
|
||||||
|
yyerror("variable not set");
|
||||||
if (str == NULL || *str == '\0')
|
if (str == NULL || *str == '\0')
|
||||||
str = "0";
|
str = "0";
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
6
tools/regression/bin/sh/expansion/set-u3.0
Normal file
6
tools/regression/bin/sh/expansion/set-u3.0
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# $FreeBSD$
|
||||||
|
|
||||||
|
set -u
|
||||||
|
unset x
|
||||||
|
v=$( (eval ': $((x))') 2>&1 >/dev/null)
|
||||||
|
[ $? -ne 0 ] && [ -n "$v" ]
|
Loading…
Reference in New Issue
Block a user