54285: 'let' builtin should return 2 if error occurred

This commit is contained in:
Jun-ichi Takimoto
2026-04-07 23:18:53 +09:00
parent 4f95c6defd
commit 9429940b7b
3 changed files with 9 additions and 3 deletions

View File

@@ -1,5 +1,8 @@
2026-04-07 Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
* 54285: Src/builtin.c, Test/C01arith.ztst: 'let' builtin
should return 2 if error occurred
* unposted: Doc/Zsh/expn.yo: fix a reference to Arithmetic
Evaluation.

View File

@@ -7501,8 +7501,11 @@ bin_let(UNUSED(char *name), char **argv, UNUSED(Options ops), UNUSED(int func))
while (*argv)
val = matheval(*argv++);
/* Errors in math evaluation in let are non-fatal. */
errflag &= ~ERRFLAG_ERROR;
if (errflag) {
/* Errors in math evaluation in let are non-fatal. */
errflag &= ~ERRFLAG_ERROR;
return 2;
}
/* should test for fabs(val.u.d) < epsilon? */
return (val.type == MN_INTEGER) ? val.u.l == 0 : val.u.d == 0.0;
}

View File

@@ -494,7 +494,7 @@
( unsetopt unset
let noexist==0 )
1:Arithmetic, NO_UNSET part 3
2:Arithmetic, NO_UNSET part 3
?(eval):2: noexist: parameter not set
print $(( "6+2" / "1+3" ))