diff options
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | Doc/Zsh/options.yo | 4 | ||||
-rw-r--r-- | README | 4 | ||||
-rw-r--r-- | Src/math.c | 2 | ||||
-rw-r--r-- | Test/C01arith.ztst | 16 |
5 files changed, 32 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog index 88e284576..ca5137636 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo index 25b3d5736..bc182eb7b 100644 --- a/Doc/Zsh/options.yo +++ b/Doc/Zsh/options.yo @@ -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) diff --git a/README b/README index aaaee5014..000210478 100644 --- a/README +++ b/README @@ -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 ------------------------------------------ diff --git a/Src/math.c b/Src/math.c index b08e05cb4..a38770073 100644 --- a/Src/math.c +++ b/Src/math.c @@ -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; diff --git a/Test/C01arith.ztst b/Test/C01arith.ztst index f1364ab36..9dfc065c8 100644 --- a/Test/C01arith.ztst +++ b/Test/C01arith.ztst @@ -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 |