SC2075 – ShellCheck Wiki

See this page on GitHub

Sitemap


Escaping \< is required in [..], but invalid in [..](..)

Problematic code:

[[ aardvark \< zebra ]]

Correct code:

[[ aardvark < zebra ]]

Rationale:

Grammatically speaking, [ is considered a normal command name, so < and > are interpreted as redirections. When using the lexicographical string operators < and > in [ .. ], they must be escaped (e.g. \< or "<").

[[ is considered its own grammatical construct, and therefore it does not require (nor does it allow) escaping < or >.

Exceptions:

None


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