From 6a51eec950b5a0f1eec46f108555fcee036673b3 Mon Sep 17 00:00:00 2001 From: Mingye Wang Date: Fri, 25 Sep 2015 10:38:31 -0400 Subject: [PATCH] Created SC2065 (markdown) --- SC2065.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 SC2065.md diff --git a/SC2065.md b/SC2065.md new file mode 100644 index 0000000..8123a5e --- /dev/null +++ b/SC2065.md @@ -0,0 +1,22 @@ +## This is interpreted as a shell file redirection, not a comparison. + +### Problematic code: + +```sh +[ 3>2 ] || [ 3>'aaa bb' ] # Simple example of problematic code +``` + +### Correct code: + +```sh +[ 3 -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. \ No newline at end of file