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

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..

Related resources:

  • Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!

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