Skip to content

Files

Latest commit

 

History

History
29 lines (17 loc) · 870 Bytes

SC2191.md

File metadata and controls

29 lines (17 loc) · 870 Bytes

Pattern: Use of literal =

Issue: -

Description

The shell doesn't care about the = sign in your array assignment because it's not part of a recognized index assignment. Instead, it's considered a literal character and becomes part of an array element's value.

Example of incorrect code:

array=( [index] = value )

Here the = was intended to set the index, but the shell will not recognize it when it is surrounded by spaces.

Make sure to remove any spaces around the = when assigning by index, such as in the correct code.

If you wanted the = to be a literal part of the array element, add quotes around it, such as env=( "LC_CTYPE=C" ) or specialChars=( "=" "%" ";" ) .

Example of correct code:

array=( [index]=value )

Further Reading