case example works for me, but note that you are comparing the concatenation of
B, so the pattern will match also if, say
B is empty. (I think the double-quotes in the middle are redundant.)
case only takes a single word to compare against the patterns, so you can't compare several variables except by concatenating.
In the standard
[ command, the comparison operator is
== works in some systems, but not all. Also, combining conditions using
-a is problematic, at least with conditions like
-n. (see this question). Better use
if [ "$A" = x ] && [ "$B" = y ] ; then ....
As for inverting a
case, you'd need to come up with a pattern that matches everything but the target string.
extglob in Bash and others allows for matching anything except:
case $B in !(y) ) echo not y ;; esac
Without it, you'd need to do some more work in inverting the pattern, or use multiple patterns with the first ones matching the string and a later default match doing the actual action.
case $B in ??*) echo not y ;; [^y]) echo also not y ;; esac
case $B in y) ;; *) echo still not y ;; esac
(no guarantees, especially on the first one. Frankly, the whole idea of doing this seems horrible.)
Anyway, since you mentioned performance reasons, you might consider changing to Perl or Python instead of the shell, not as much because of simple comparisons, but because they'll allow you to do more without calling external programs (like
jq). Also, the first rule of performance optimizations: measure the difference.