Skip to content
Vidar Holen edited this page Jul 24, 2021 · 2 revisions

Remove spaces around = to assign.

Problematic code:

export LC_ALL = "POSIX"

Correct code:

export LC_ALL="POSIX"

Rationale:

Parameters to export, declare, local, typeset and readonly may not have spaces around the = or += operator. This is the same as for regular variable assignments:

export var = value   # Invalid: spaces around =
export var =value    # Invalid: space before =
export var= value    # Invalid: space after =
export var=value     # Valid

This is because each individual argument to these commands is interpreted as a string in the format name=value. By adding spaces, you are instead passing the three strings var, =, value, none of which follow this format.

Exceptions:

None

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 above to find a specific one, or see Checks.

Clone this wiki locally