let arg [arg ...]
The let builtin command evaluates each supplied word from left to right as an arithmetic expression and returns an exit code according to the truth value of the rightmost expression.
arg evaluated to not 0 (arithmetic "true")arg evaluated to 0 (arithmetic "false")
For this return code mapping, please see this section. They work in the same way as ((.
$ let 'b = a' "(a += 3) + $((a = 1)), b++" $ echo "$a - $b - $?" 4 - 2 - 0
Is equivalent to the arithmetic evaluation compound command
$ (( b = a, (a += 3) + $((a = 1)), b++ )) $ echo "$a - $b - $?" 4 - 2 - 0
The latter is almost always preferred. No wordsplitting or pathname expansion occurs within the arithmetic command. However, all the usual expansions and argument passing rules which apply to ordinary simple commands also apply to let. Be careful about quoting and escaping. A rough analogy: [ : [[ :: let : ((, except that let has no standalone command and is non-standard.
let command is not specified by POSIX®. The standard equivalent is: [ "$(( <EXPRESSION> ))" -ne 0 ]
let, the above should always be preferred. Both arithmetic expansions and the [ test operator are specified by POSIX® and satisfy almost all of expr's use-cases. Unlike let, expr cannot assign directly to bash variables but instead returns a result on stdout. expr takes each operator it recognizes as a separate word and then concatenates them into a single expression that's evaluated according to it's own rules (which differ from shell arithmetic). let parses each word it recieves on its own and evaluates it as an expression without generating any output other than a return code.
Discussion
I believe the internal links to "arithmetic expansion" should be directed here:
http://wiki.bash-hackers.org/syntax/expansion/arith
Instead of:
http://wiki.bash-hackers.org/syntax/arith_expr
Just an fyi...
Of course, my bad...
Thanks