Skip to content
Joachim Ansorg edited this page Nov 12, 2021 · 3 revisions

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

time is undefined for compound commands, use time sh -c instead.

Problematic code:

time for i in *.bmp; do convert "$i" "$i.png"; done

Correct code:

time sh -c 'for i in *.bmp; do convert "$i" "$i.png"; done'

Rationale:

time is only defined for Simple Commands by POSIX. Timing loops, command groups and similar is not.

Exceptions:

None. If you use a shell that supports this (e.g. bash, ksh), specify this shell in the shebang.