On the paragraph explaining arithmetic expansion, Bash's user guide uncovers 2 different ways of evaluating an expression, the first one uses $(( EXPRESSION ))
and the second one uses $[ EXPRESSION ]
. The two ways seem pretty similar as the only difference I have found is:
$[ EXPRESSION ]
will only calculate the result of EXPRESSION, and do no tests:
Yet, I am intrigued because the same document recommends using $[ EXPRESSION ]
rather than $(( EXPRESSION ))
.
Wherever possible, Bash users should try to use the syntax with square brackets:
Why would you want that if less tests are being done?