SC2285 – ShellCheck Wiki

See this page on GitHub

Sitemap


Remove spaces around += to assign (or quote '+=' if literal).

Problematic code:

var += "my text"

Correct code:

var+="my text"

Rationale:

ShellCheck found an unquoted += after a word. To append text to a variable, remove spaces around += as in the example.

Exceptions:

If the += was supposed to be literal, you can quote it to make ShellCheck ignore it:

grep '+=' files..

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