Skip to content
Joachim Ansorg edited this page Nov 12, 2021 · 2 revisions

Missing $ on a $((..)) expression? (or use ( ( for arrays).

Problematic code:

var=((foo+1))

Correct code:

var=$((foo+1))

Rationale:

You appear to be missing the $ on an assignment from an arithmetic expression var=$((..)) .

Without the $, this is an array expression which is either nested (ksh) or invalid (bash).

Exceptions:

If you are trying to define a multidimensional Ksh array, add spaces between the ( ( to clarify:

var=( (1 2 3) (4 5 6) )

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature guerraart8 to find a specific , or see Checks.

Clone this wiki locally