mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC1097 (markdown)
29
SC1097.md
Normal file
29
SC1097.md
Normal file
@@ -0,0 +1,29 @@
|
||||
## Unexpected ==. For assignment, use =. For comparison, use [/[[.
|
||||
|
||||
### Problematic code:
|
||||
|
||||
var==value
|
||||
|
||||
### Correct code:
|
||||
|
||||
Assignment:
|
||||
|
||||
var=value
|
||||
|
||||
Comparison:
|
||||
|
||||
[ "$var" = value ]
|
||||
|
||||
### Rationale:
|
||||
|
||||
ShellCheck has noticed that you're using `==` in an unexpected way. The two most common reasons for this is:
|
||||
|
||||
* You wanted to assign a value but accidentally used `==` instead of `=`.
|
||||
|
||||
* You wanted to compare two values, but neglected to use `[ .. ]` or `[[ .. ]]`.
|
||||
|
||||
### Exceptions:
|
||||
|
||||
If you wanted to assign a literal equals sign, use quotes to make this clear:
|
||||
|
||||
var="=sum(A1:A10)"
|
Reference in New Issue
Block a user