mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC1116 (markdown)
25
SC1116.md
Normal file
25
SC1116.md
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
## Missing $ on a $((..)) expression? (or use ( ( for arrays).
|
||||||
|
|
||||||
|
### Problematic code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
var=((foo+1))
|
||||||
|
```
|
||||||
|
|
||||||
|
### Correct code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
var=$((foo+1))
|
||||||
|
```
|
||||||
|
|
||||||
|
### Rationale:
|
||||||
|
|
||||||
|
You appear to be missing the `$` on an assignment from an arithmetic expression `var=$((..))` .
|
||||||
|
|
||||||
|
Without the `$`, this is an array expression which is either nested (ksh) or invalid (bash).
|
||||||
|
|
||||||
|
### Exceptions:
|
||||||
|
|
||||||
|
If you are trying to define a multidimensional Ksh array, add spaces between the `( (` to clarify:
|
||||||
|
|
||||||
|
var=( (1 2 3) (4 5 6) )
|
Reference in New Issue
Block a user