Skip to content

assignment-space

Shellcorrectnessno fixdefault: offshell/shellcheck

Reports a command prefix var= cmd, at the start of the command.

The space ends the assignment, so var is set to the empty string for cmd, and cmd runs. var=value cmd was almost always meant.

To fix, remove the space, or quote the empty value if it is meant (var="" cmd).

Reported
...
echo "$@" "${s[@]}"
PGHOST= psql
IFS= read -r line
PGHOST=db psql
...
shell:
lint:
rules:
assignment-space: warn # off (default), warn, error

Enabled by the presets: shell/shellcheck.

Suppress one line with sudsy-disable-next-line assignment-space in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
shellcheck SC1007 partial Only a command prefix var= cmd (not IFS=), reported at the start of the command.