Skip to content

Files

Latest commit

 

History

History
49 lines (32 loc) · 1.29 KB

SC2057.md

File metadata and controls

49 lines (32 loc) · 1.29 KB

Pattern: Unknown binary operator in test expression

Issue: -

Description

You are using an unknown binary operator in a test expression. Choose one that exists.

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.

Example of incorrect code:

[ "$var" -leq 42 ]

Example of correct code:

[ "$var" -le 42 ]

Further Reading