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

This is interpreted as a shell file redirection, not a comparison.

Problematic code:

[ 1 >2 ] || [ 3>'aaa bb' ] # Simple example of problematic code

Correct code:

[ 1 -gt 2 ] || [ 3 \> 'aaa bb' ] # arithmetical, lexicographical

Rationale:

A word that looks like a redirection in simple shell commands causes it to be interpreted as a redirection. ShellCheck would guess that you don't want it in tests.

Exceptions:

When it's among a continuous list of redirections at the end of a simple test command, it's more likely that the user really meant to do a redirection. Or any other case that you mean to do that.

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