mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC1108 (markdown)
22
SC1108.md
Normal file
22
SC1108.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
## You need a space before and after the = .
|
||||||
|
|
||||||
|
### Problematic code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
[ "$var"= 2 ]
|
||||||
|
```
|
||||||
|
|
||||||
|
### Correct code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
[ "$var" = 2 ]
|
||||||
|
```
|
||||||
|
### Rationale:
|
||||||
|
|
||||||
|
You appear to be missing the space on the left side of the operator. Shell in general, and `[` in particular, is space sensitive. Operators and operands must be separate tokens.
|
||||||
|
|
||||||
|
Please ensure that the operator, like the `=` in the example, has a space both before and after it.
|
||||||
|
|
||||||
|
### Exceptions:
|
||||||
|
|
||||||
|
None. If you're comparing values in C style reverse order like `[ -eq == $1 ]`, use quotes: `[ "-eq" == "$1" ]`. Also, it's pointless since `[ a = b ]` doesn't assign.
|
Reference in New Issue
Block a user