aboutsummaryrefslogtreecommitdiff
path: root/shell/math.c
diff options
context:
space:
mode:
Diffstat (limited to 'shell/math.c')
-rw-r--r--shell/math.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/shell/math.c b/shell/math.c
index d5f3ce361..9ca7c6bb1 100644
--- a/shell/math.c
+++ b/shell/math.c
@@ -435,10 +435,11 @@ arith_apply(arith_state_t *math_state, operator op, var_or_num_t *numstack, var_
435 c *= rez; 435 c *= rez;
436 rez = c; 436 rez = c;
437 } 437 }
438 else if (right_side_val == 0) 438 else /*if (op == TOK_DIV || op == TOK_DIV_ASSIGN
439 return "divide by zero"; 439 || op == TOK_REM || op == TOK_REM_ASSIGN) - always true */
440 else if (op == TOK_DIV || op == TOK_DIV_ASSIGN 440 {
441 || op == TOK_REM || op == TOK_REM_ASSIGN) { 441 if (right_side_val == 0)
442 return "divide by zero";
442 /* 443 /*
443 * bash 4.2.45 x86 64bit: SEGV on 'echo $((2**63 / -1))' 444 * bash 4.2.45 x86 64bit: SEGV on 'echo $((2**63 / -1))'
444 * 445 *
@@ -456,9 +457,8 @@ arith_apply(arith_state_t *math_state, operator op, var_or_num_t *numstack, var_
456 } 457 }
457 if (op == TOK_DIV || op == TOK_DIV_ASSIGN) 458 if (op == TOK_DIV || op == TOK_DIV_ASSIGN)
458 rez /= right_side_val; 459 rez /= right_side_val;
459 else { 460 else
460 rez %= right_side_val; 461 rez %= right_side_val;
461 }
462 } 462 }
463 } 463 }
464 464