mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Updated SC2124 (markdown)
10
SC2124.md
10
SC2124.md
@@ -50,3 +50,13 @@ The same is true for `${@: -1}`, which results in 0 or 1 elements: `var=${*: -1}
|
|||||||
### Exceptions
|
### Exceptions
|
||||||
|
|
||||||
None.
|
None.
|
||||||
|
|
||||||
|
### Adding an element to an array may trigger this warning when you forget the parenthesis.
|
||||||
|
```
|
||||||
|
filelist="${filelist[@]}" "$filename"
|
||||||
|
```
|
||||||
|
What was meant is:
|
||||||
|
```
|
||||||
|
filelist=("${filelist[@]}" "$filename")
|
||||||
|
```
|
||||||
|
Note: this syntax is compatible with older shells, in later shells (bash 3.1+ and zsh 4.2+) you can do: ```filelist+=("$filename")```
|
||||||
|
Reference in New Issue
Block a user