From 43313c51180ed7ed8f0ed88df5f51eaa3a7bba9e Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Wed, 30 Dec 2020 19:45:34 -0800 Subject: [PATCH] Created SC2272 (markdown) --- SC2272.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 SC2272.md diff --git a/SC2272.md b/SC2272.md new file mode 100644 index 0000000..8e3e9fb --- /dev/null +++ b/SC2272.md @@ -0,0 +1,26 @@ +## Command name contains ==. For comparison, use [ "$var" = value ]. + +### Problematic code: + +```sh +$a/$b==foo/bar +``` + +### Correct code: + +```sh +[ "$a/$b" = "foo/bar" ] +``` +### Rationale: + +ShellCheck found a command name that contains a `==`. Most likely, this was intended as a kind of comparison. + +To compare two values, use `[ value1 = value2 ]`. Both the brackets and the spaces around the `=` are relevant. + +### Exceptions: + +None, though you can quote the `==` to suppress the warning. + +### Related resources: + +* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc! \ No newline at end of file