From 55482b9f208698dafa36a718e02f12232f2108dd Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Wed, 19 Oct 2022 21:22:00 -0700 Subject: [PATCH] Created SC2042 (markdown) --- SC2042.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 SC2042.md diff --git a/SC2042.md b/SC2042.md new file mode 100644 index 0000000..0f83803 --- /dev/null +++ b/SC2042.md @@ -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! \ No newline at end of file