[[ is bash reserved word, therefore special expansion rules such as arithmetic expansion are applied, not like in case with
[. Also arithmetic binary operator
-eq is used. Therefore shell looks for integer expression and if text is found at the first item it tries to expand it as parameter. It is called arithmetic expansion and is present in
Reserved words are words that have a special meaning to the shell.
The following words are recognized as reserved
[[ expression ]]
Return a status of 0 or 1 depending on the evaluation of
the conditional expression 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 ]]; tilde
expansion, parameter and variable expansion, >>>_arithmetic
expansion_<<<, command substitution, process substitution, and
quote removal are performed.
The evaluation is performed according to the rules listed below
under ARITHMETIC EVALUATION.
Within an expression, shell variables may also be referenced
by name without using the parameter expansion syntax.
So for example:
[[ hdjakshdka -eq fkshdfwuefy ]]
will return always true
But this one will return error
$ [[ 1235hsdkjfh -eq 81749hfjsdkhf ]]
-bash: [[: 1235hsdkjfh: value too great for base (error token is "1235hsdkjfh")
Also recursion is available:
$ VALUE=VALUE ; [[ VALUE -eq 12 ]]
-bash: [[: VALUE: expression recursion level exceeded (error token is "VALUE")