Skip to content
Joachim Ansorg edited this page Oct 31, 2022 · 2 revisions

Can't have empty do clauses (use true as a no-op)

Problematic code:

for i in 1 2 3; do
done

Correct code:

for i in 1 2 3; do
  true
done

Rationale:

An empty do ... done block is not valid. Use true or : if you need no command at all.

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