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