SC3024 – ShellCheck Wiki

See this page on GitHub

Sitemap


In POSIX sh, += is undefined.

(or "In dash, ... is not supported." when using dash)

Problematic code:

var="Hello "
var+="World"

Correct code:

var="Hello "
var="${var}World"

Rationale:

Using += to concatenate to an existing variable is a ksh/bash extension. For POSIX sh or dash, write out the full expression. Be careful to use braces if the text you append could be confused for a variable (as in the example, to avoid $varWorld being interpreted as ${varWorld})

Exceptions:

None.


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