Bash – Understanding [[ = ]] Behavior

bash

man bash:

[[ expression ]]
[…]
Expressions are composed of the primaries described below under CONDITIONAL EXPRESSIONS. Word splitting and pathname expansion are not performed on the words between the [[ and ]];
[…]
When the == and != operators are used, the string to the right of the operator is considered a pattern and matched according to the rules described below under Pattern Matching.

In the whole section the case of a single = is not mentioned.

CONDITIONAL EXPRESSIONS
[…]
string1 == string2
string1 = string2
True if the strings are equal. = should be used with the test command for POSIX conformance.

From this description I would expect that

[[ a = $cmpstring ]]

checks for equal strings and

[[ a == $cmpstring ]]

checks for a pattern match. But that is not the case:

> [[ a == ? ]]; echo $?
0
> [[ a = ? ]]; echo $?
0
> [[ a == "?" ]]; echo $?
1

Do I misunderstand something or has the bash man page just forgotten to mention =?

Best Answer

= is the same as == when inside [[...]]. As per the more recent man page, under SHELL GRAMMAR > Compound Commands > [[ expression ]]:

The = operator is equivalent to ==

and further down, under CONDITIONAL EXPRESSIONS:

string1 == string2
string1 = string2
        True  if  the  strings  are equal.  = should be used with the test command
        for POSIX conformance. When used with the [[ command, this performs pattern
        matching as described above (Compound Commands).

bash info page:

enter image description here