mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC1066 (markdown)
23
SC1066.md
Normal file
23
SC1066.md
Normal file
@@ -0,0 +1,23 @@
|
||||
## 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
|
Reference in New Issue
Block a user