mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC2042 (markdown)
30
SC2042.md
Normal file
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!
|
Reference in New Issue
Block a user