[[
adalah kata yang dilindungi undang-undang, oleh karena itu aturan ekspansi khusus seperti ekspansi aritmatika diterapkan, tidak seperti halnya dengan [
. Juga operator biner aritmatika -eq
digunakan. Oleh karena itu shell mencari ekspresi integer dan jika teks ditemukan pada item pertama ia mencoba untuk memperluasnya sebagai parameter. Ini disebut ekspansi aritmatika dan hadir di man bash
.
RESERVED WORDS
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.
Arithmetic Expansion
…
The evaluation is performed according to the rules listed below
under ARITHMETIC EVALUATION.
ARITHMETIC EVALUATION
…
Within an expression, shell variables may also be referenced
by name without using the parameter expansion syntax.
Jadi misalnya:
[[ hdjakshdka -eq fkshdfwuefy ]]
akan kembali selalu benar
Tapi ini akan mengembalikan kesalahan
$ [[ 1235hsdkjfh -eq 81749hfjsdkhf ]]
-bash: [[: 1235hsdkjfh: value too great for base (error token is "1235hsdkjfh")
Rekursi juga tersedia:
$ VALUE=VALUE ; [[ VALUE -eq 12 ]]
-bash: [[: VALUE: expression recursion level exceeded (error token is "VALUE")