Skip to content
Rushen Wang edited this page Sep 9, 2024 · 1 revision

The trailing comma is part of the value, not a separator. Delete or quote it.

Problematic code:

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

Correct code:

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

or

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!

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature above to find a specific one, or see Checks.

Clone this wiki locally