Skip to content
koalaman edited this page Aug 12, 2014 · 15 revisions

Include a shebang (#!) to specify the shell.

Problematic code:

echo "Hello World"

Correct code:

#!/bin/sh
echo "Hello World"

Rationale:

ShellCheck noticed that your file does not start with a shebang. Shebangs are good for a number of reasons:

  • They allow scripts to be executed outside of interactive prompts.
  • They ensure the script is executed by the correct shell.
  • Editors and utilities (including shellcheck) use it to determine the file type.

Contraindications

For checking snippets, use shellcheck -e 2148. This is the default for shellcheck.net.

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