SC1033 – ShellCheck Wiki

See this page on GitHub

Sitemap


Test expression was opened with double [[ but closed with single ]. Make sure they match.

(or SC1034 for vice versa)

Problematic code:

[[ -z "$var" ]

Correct code:

[[ -z "$var" ]]

Rationale:

ShellCheck found a test expression [ ... ] (POSIX) or [[ ... ]] (ksh/bash), but where the opening and closing brackets did not match (i.e. [[ .. ] or [ .. ]]). The brackets need to match up to work.

Note in particular that [..] do not work like parentheses in other languages. You can not do:

# Invalid
[[ x ] || [ y ]]

You would instead use two separate test expressions joined by ||:

# Valid basic test expressions (sh/bash/ksh)
[ x ] || [ y ]

# Valid extended test expressions (bash/ksh)
[[ x ]] || [[ y ]]

Exceptions:

None


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