1 SC2042
Vidar Holen edited this page 2022-10-19 21:22:00 -07:00

Use spaces, not commas, to separate loop elements.

Problematic code:

for f in foo,bar,baz
do
  echo "$f"
done

Correct code:

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

  • Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!