From 90d16d3155d7bf09ec00338914ff38474b55f492 Mon Sep 17 00:00:00 2001 From: Rushen Wang <45029442+dovics@users.noreply.github.com> Date: Mon, 9 Sep 2024 20:46:46 +0800 Subject: [PATCH] Created SC2258 (markdown) --- SC2258.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 SC2258.md 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