Pattern: Use of doubly nested parentheses
Issue: -
ShellCheck found doubly nested parentheses in an arithmetic expression. While the syntax for an arithmetic expansion is $((..))
, this does not imply that parentheses in the expression should also be doubled. (x)
, ((x))
, and (((x)))
are all identical, so you might as well use only one layer of parentheses.
Example of incorrect code:
value=$(( ((offset + index)) * 512 ))
Example of correct code:
value=$(( (offset + index) * 512 ))