mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC1068 (markdown)
17
SC1068.md
Normal file
17
SC1068.md
Normal file
@@ -0,0 +1,17 @@
|
||||
# Don't put spaces around the = in assignments.
|
||||
|
||||
### Problematic code:
|
||||
|
||||
foo = 42
|
||||
|
||||
### Correct code:
|
||||
|
||||
foo=42
|
||||
|
||||
### Rationale:
|
||||
|
||||
Shells are space sensitive. `foo=42` means to assign `42` to the variable `foo`. `foo = 42` means to run a command named `foo`, and pass `=` as `$1` and `42` as `$2`.
|
||||
|
||||
### Contraindications
|
||||
|
||||
If you actually wanted to run a command named foo and provide `=` as the first argument, simply quote it to make ShellCheck be quiet: `foo "=" 42`.
|
Reference in New Issue
Block a user