Open rassie opened 4 years ago
Then don’t you want = instead of !=?
No, since !=
means "match" in this case. If I want to match for bar
and compare foobar
with foo
(foobar
without bar
) and there aren't equal, then it's a match. If I instead compare fuzzbuzz
with fuzzbuzz
(fuzzbuzz
without bar
), those are equal, which means it's not a match. Complicated, I know :)
For bugs
shellcheck --version
or "online"): 0.7.0Here's a snippet or screenshot that shows the problem:
Here's what shellcheck currently says:
SC2252: You probably wanted && here, otherwise it's always true.
Here's what I wanted or expected to see:
This expression is perfectly valid and not always true. The idea is to check for string prefix match in
$A
, which has to be eithersubstring1
,substring2
orsubstring3
to execute the code in thethen
block. Since I can't use bash pattern globs, a technique is used which compares the original string with the same string without a prefix to get the idea whether the original string actually starts with that prefix. I would expectshellcheck
not to warn about this expression.