Created SC2258 (markdown)

Rushen Wang
2024-09-09 20:46:46 +08:00
parent 8b9e81f08f
commit 90d16d3155

39
SC2258.md Normal file

@@ -0,0 +1,39 @@
## The trailing comma is part of the value, not a separator. Delete or quote it.
### 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
```
or
```sh
for f in "foo," "bar," "baz,"
do
echo "$f"
done
```
### Rationale:
ShellCheck found a `for` loop where the items appear to be separated by commas. These will be treated as literal commas. If the commas are part of the value, enclose them in quotes, or remove them.
### Exceptions:
None
### Related resources:
* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!