Skip to content
koalaman edited this page Oct 31, 2014 · 6 revisions

Don't use $ on the left side of assignments.

Problematic code:

$greeting="Hello World"

Correct code:

greeting="Hello World"

Alternatively, if the goal was to assign to a variable whose name is in another variable (indirection), use declare:

name=foo
declare "$name=hello world"
echo "$foo"

Rationale:

Unlike Perl or PHP, $ is not used when assigning to a variable.

Contraindications

None

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