Pattern: Initializing/appending array element to an associative array without index
Issue: -
You appear to be initializing or appending an array element to an associative array without giving it an index. In an indexed array, elements will be auto-indexed by incremented characters. In associative arrays, the index must be given explicitly.
This could happen because of invalid spaces or otherwise malformed index assignment, such as array=( [key] = value )
. This should instead be array=( [key]=value )
.
Example of incorrect code:
declare -A foo
foo=( somevalue )
Example of correct code:
declare -A foo
foo=( [key]=somevalue )