SC2321 – ShellCheck Wiki

See this page on GitHub

Sitemap


Array indices are already arithmetic contexts. Prefer removing the $(( and )).

Problematic code:

values[$((i+1))]=1

Correct code:

values[i+1]=1

Rationale:

In indexed arrays (but not associative ones), the array index is already an arithmetic context. There is no point or value in wrapping it in an additional, explicit $((..)).

Exceptions:

If ShellCheck has failed to realize that your array is associative, or if you for stylistic reasons prefer the redundancy, you can ignore this message.


ShellCheck is a static analysis tool for shell scripts. This page is part of its documentation.