mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
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
2 changed files with 8 additions and 0 deletions
|
|
@ -97,6 +97,8 @@ static arith_t arith_lookupvarint(char *varname)
|
|||
arith_t result;
|
||||
|
||||
str = lookupvar(varname);
|
||||
if (uflag && str == NULL)
|
||||
yyerror("variable not set");
|
||||
if (str == NULL || *str == '\0')
|
||||
str = "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 a new issue