Bash.Builtin.Let (Bash v0.6.0)

Copy Markdown View Source

let arg [arg ...] (( expression ))

Evaluate arithmetic expressions.

Each ARG is an arithmetic expression to be evaluated. Evaluation is done in fixed-width integers with no check for overflow, though division by 0 is trapped and flagged as an error.

Operator precedence (highest to lowest): id++, id-- variable post-increment, post-decrement ++id, --id variable pre-increment, pre-decrement -, + unary minus, plus !, ~ logical and bitwise negation * exponentiation , /, % multiplication, division, remainder +, - addition, subtraction <<, >> left and right bitwise shifts <=, >=, <, > comparison ==, != equality, inequality & bitwise AND ^ bitwise exclusive OR | bitwise OR && logical AND || logical OR expr ? expr : expr

                conditional operator

=, *=, /=, %=, +=, -=, <<=, >>=, &=, ^=, |= assignment

Shell variables are allowed as operands. Variable names are replaced by their values (coerced to integers). No $ prefix is needed.

Exit Status: If the last ARG evaluates to 0, let returns 1; let returns 0 otherwise.

Reference: https://cgit.git.savannah.gnu.org/cgit/bash.git/plain/builtins/let.def?h=bash-5.3