pub fn bash_test_eq_count(test: &Node<'_>) -> usizeExpand description
How many = string comparisons test, a [ … ] / [[ … ]]
test_command, holds.
Both spellings of = are a binary_expression: [ "$a" = 1 ]
compares and (( x = 1 )) assigns. So an = compares exactly when
the test reaches it through expression nodes alone. The descent
passes through binary_expression because tree-sitter-bash nests =
wrongly — [ "$a" = 1 -a "$b" = 2 ] parses as
"$a" = (1 -a "$b") = 2 — and through the unary and parenthesized
forms ([[ ! ( "$a" = 1 ) ]]). It stops at anything else, so the
assignment in [[ $(( x = 1 )) -eq 1 ]] is not counted.
Counted from the test down rather than by climbing from each = to
its test: on the mis-nested spine a climb per = is O(depth), and a
long [ … = … -o … ] made the walk quadratic. The descent is an
explicit stack, since that spine is as deep as the test is long.