Skip to content
Vidar Holen edited this page Oct 4, 2015 · 3 revisions

You need spaces around the comparison operator.

Problematic code:

[[ 0=1 ]]

Correct code:

[[ 0 = 1 ]]

Rationale:

[[ 0 = 1 ]] means "check if 0 and 1 are equal".

[[ str ]] is short form for [[ -n str ]], and means "check if str is non-empty". It doesn't matter if str happens to contain 0=1.

Always use spaces around the comparison operator in [..] and [[..]], otherwise it won't be recognized as an operator.

Exceptions

None.

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