Skip to content

Files

Latest commit

 

History

History
27 lines (17 loc) · 782 Bytes

SC2190.md

File metadata and controls

27 lines (17 loc) · 782 Bytes

Pattern: Initializing/appending array element to an associative array without index

Issue: -

Description

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 )

Further Reading