Created SC2042 (markdown)

Vidar Holen
2022-10-19 21:22:00 -07:00
parent 306a5f5977
commit 55482b9f20

30
SC2042.md Normal file

@@ -0,0 +1,30 @@
## Use spaces, not commas, to separate loop elements.
### Problematic code:
```sh
for f in foo,bar,baz
do
echo "$f"
done
```
### Correct code:
```sh
for f in foo bar baz
do
echo "$f"
done
```
### Rationale:
ShellCheck found a `for` loop where the items appeared to be delimited by commas. These will be treated as literal commas. Use spaces instead.
### Exceptions:
None
### Related resources:
* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!