Skip to content

Arithmetic: recursive variable deref, array access, quoted substitution not implemented #361

@chaliy

Description

@chaliy

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions