From 4dd476ab471f60554314027dfe009acf89ed0bf6 Mon Sep 17 00:00:00 2001 From: koalaman Date: Sat, 10 May 2014 12:50:32 -0700 Subject: [PATCH] Created SC2130 (markdown) --- SC2130.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 SC2130.md diff --git a/SC2130.md b/SC2130.md new file mode 100644 index 0000000..6f31cc8 --- /dev/null +++ b/SC2130.md @@ -0,0 +1,19 @@ +## -eq is for integer comparisons. Use = instead. + +### Problematic code: + + [[ $foo -eq "Y" ]] + +### Correct code: + + [[ $foo = "Y" ]] + +### Rationale: + +Shells have two sets of comparison operators: for integers (`-eq`, `-gt`, ...) and strings (`=`, `>`, ...). ShellCheck has noticed that you're using an integer comparison with string data. + +If you are in fact comparing integers, double check your parameters. Certain mistakes like `$$foo` or `${bar}}` can introduce non-numeric characters into otherwise numeric arguments. + +### Contraindications + +None.