43944: apply NO_UNSET consistently to arithmeitc

This commit is contained in:
Martijn Dekker 2018-12-25 17:18:57 +00:00 committed by Peter Stephenson
parent d0f92b448e
commit 4215fcb107
5 changed files with 32 additions and 1 deletions

View File

@ -1,3 +1,10 @@
2018-12-30 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 43944: Martijn: Doc/Zsh/options.yo, README, Src/math.c,
Test/C01arith.ztst: apply NO_UNSET consistently to arithmetic.
* unposted: Test/D04parameter.ztst: test for 43938.
2018-12-30 dana <dana@dana.is>
* 43914 (tweaked): Completion/Unix/Command/_composer: Add

View File

@ -753,7 +753,9 @@ pindex(NOUNSET)
cindex(parameters, substituting unset)
cindex(unset parameters, substituting)
item(tt(UNSET) (tt(PLUS()u), ksh: tt(PLUS()u)) <K> <S> <Z>)(
Treat unset parameters as if they were empty when substituting.
Treat unset parameters as if they were empty when substituting, and as if
they were zero when reading their values in arithmetic expansion and
arithmetic commands.
Otherwise they are treated as an error.
)
pindex(WARN_CREATE_GLOBAL)

4
README
View File

@ -42,6 +42,10 @@ array.
The gen-applied-string hook is unaffected; it still receives the patches in
reverse order, from last applied to first applied.
2) The option NO_UNSET now also applies when reading values from
variables without a preceding '$' sign in shell arithmetic expansion
and in the double-parentheses and 'let' arithmetic commands.
Incompatibilities between 5.5.1 and 5.6.2
------------------------------------------

View File

@ -342,6 +342,8 @@ getmathparam(struct mathvalue *mptr)
mptr->pval = (Value)zhalloc(sizeof(struct value));
if (!getvalue(mptr->pval, &s, 1))
{
if (unset(UNSET))
zerr("%s: parameter not set", mptr->lval);
mptr->pval = NULL;
if (isset(FORCEFLOAT)) {
result.type = MN_FLOAT;

View File

@ -471,3 +471,19 @@
print $(( -2#101-16#f ))
0: Unary minus doesn't apply to base but to number as a whole.
>-20
( set -o nounset
true $(( noexist + 1 ))
echo 'should never get here' )
1:Arithmetic, NO_UNSET part 1
?(eval):2: noexist: parameter not set
( setopt nounset
(( noexist++ )) )
2:Arithmetic, NO_UNSET part 2
?(eval):2: noexist: parameter not set
( unsetopt unset
let noexist==0 )
1:Arithmetic, NO_UNSET part 3
?(eval):2: noexist: parameter not set