DeepSource has joined Harness. Learn more
Shell logoShell/
SH-1066

`$` used on the left side of an assignmentSH-1066

Critical severityCritical
Bug Risk categoryBug Risk

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

Problematic code:

$greeting="Hello World"

Preferred 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"