From 11f3416da377e404c48053b9e49b9d3e6987bafd Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sat, 17 Feb 2018 16:00:05 -0800 Subject: [PATCH] Created SC2057 (markdown) --- SC2057.md | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 SC2057.md diff --git a/SC2057.md b/SC2057.md new file mode 100644 index 0000000..ad56395 --- /dev/null +++ b/SC2057.md @@ -0,0 +1,53 @@ +## Unknown binary operator. + +### Problematic code: + +```sh +[ "$var" -leq 42 ] +``` + +### Correct code: + +```sh +[ "$var" -le 42 ] +``` + +### Rationale: + +You are using an unknown binary operator in a `test` expression. In bash, use `help test` to see a list of supported operators: + + FILE1 -nt FILE2 True if file1 is newer than file2 (according to + modification date). + + FILE1 -ot FILE2 True if file1 is older than file2. + + FILE1 -ef FILE2 True if file1 is a hard link to file2. + + STRING1 = STRING2 + True if the strings are equal. + STRING1 != STRING2 + True if the strings are not equal. + STRING1 < STRING2 + True if STRING1 sorts before STRING2 lexicographically. + STRING1 > STRING2 + True if STRING1 sorts after STRING2 lexicographically. + + arg1 OP arg2 Arithmetic tests. OP is one of -eq, -ne, + -lt, -le, -gt, or -ge. + + Arithmetic binary operators return true if ARG1 is equal, not-equal, + less-than, less-than-or-equal, greater-than, or greater-than-or-equal + than ARG2. + +The operators + + +### Exceptions: + +None. If you've tested and verified that the operator works, please [submit a bug report](https://github.com/koalaman/shellcheck/issues). + +### Related resources: + +* [The classic test command](http://wiki.bash-hackers.org/commands/classictest) on the Bash Hackers wiki. +* [The conditional expression](http://wiki.bash-hackers.org/syntax/ccmd/conditional_expression) on the Bash Hackers wiki. +* [Tests and conditionals](https://mywiki.wooledge.org/BashGuide/TestsAndConditionals) on the Wooledge BashGuide. \ No newline at end of file