diff --git a/SC2258.md b/SC2258.md new file mode 100644 index 0000000..25635da --- /dev/null +++ b/SC2258.md @@ -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! \ No newline at end of file