Description
Several dynamic arithmetic features are missing.
Scope
- Recursive variable dereferencing:
b=a; a=3; echo $((b+1)) should output 4 (deref b to a to 3), but outputs 1
- Variable expression re-evaluation:
x='1 + 2'; echo $((x * 3)) should output 9 (re-evaluate x as expression), but outputs 7
- Array access in arithmetic:
arr=(10 20 30); echo $((arr[1])) should output 20, but outputs 0
- Array index expressions:
echo $((arr[1+1])) should work
- Quoted substitution:
echo $(("$x" * 3)) should work
Repro
a=3
b=a
echo $(( b + 1 ))
# bashkit outputs: 1 (wrong — treats 'a' as 0)
# expected: 4 (dereferences b->a->3)
arr=(10 20 30 40)
i=2
echo $(( arr[i] ))
# bashkit outputs: 0 (wrong)
# expected: 30
Test coverage
5 skipped tests in crates/bashkit/tests/spec_cases/bash/arith-dynamic.test.sh (PR #351).
Oils reference: https://github.com/oilshell/oil/blob/master/spec/arith-dynamic.test.sh
Description
Several dynamic arithmetic features are missing.
Scope
b=a; a=3; echo $((b+1))should output4(derefbtoato3), but outputs1x='1 + 2'; echo $((x * 3))should output9(re-evaluatexas expression), but outputs7arr=(10 20 30); echo $((arr[1]))should output20, but outputs0echo $((arr[1+1]))should workecho $(("$x" * 3))should workRepro
Test coverage
5 skipped tests in
crates/bashkit/tests/spec_cases/bash/arith-dynamic.test.sh(PR #351).Oils reference: https://github.com/oilshell/oil/blob/master/spec/arith-dynamic.test.sh