SC2215 – ShellCheck Wiki

See this page on GitHub

Sitemap


This flag is used as a command name. Bad line break or missing [ .. ]?

Problematic code:

if -e .bashrc
then
  echo ".bashrc already exists"
fi

or

find . -name '*.mkv'
       -exec mplayer {} \;

Correct code:

if [ -e .bashrc ]
then
  echo ".bashrc already exists"
fi

or

find . -name '*.mkv' \
       -exec mplayer {} \;

Rationale:

You are using a name that starts with a dash as a command name. This is almost always a bug.

There are two typical ways in which this happens:

Exceptions:

If you actually have a command that starts with a dash -- which you should really reconsider -- you can quote the name (or at least the leading dash). This makes no difference to the shell, but makes it clear to ShellCheck and humans that this is not intended as a flag.


ShellCheck is a static analysis tool for shell scripts. This page is part of its documentation.