Skip to content

fix(interpreter): expand special variables ($#, $?, etc.) in arithmetic#887

Merged
chaliy merged 1 commit intomainfrom
fix/issue-876-special-vars-arithmetic
Mar 28, 2026
Merged

fix(interpreter): expand special variables ($#, $?, etc.) in arithmetic#887
chaliy merged 1 commit intomainfrom
fix/issue-876-special-vars-arithmetic

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Mar 27, 2026

Summary

  • Special variables like $#, $?, $$ were not expanded inside (( )) arithmetic because expand_arithmetic_vars_depth only consumed alphanumeric/underscore chars after $
  • Add handling for special variable characters (#, ?, $, !, @, *, -) in the arithmetic variable expansion
  • Add spec tests arith_special_var_hash and arith_special_var_question

Test plan

  • New spec tests pass
  • All 1812 bash spec tests pass (100%)
  • Full cargo test --all-features passes
  • cargo fmt --check and cargo clippy clean

Closes #876

Special shell variables like $# were not recognized by
expand_arithmetic_vars_depth because it only consumed alphanumeric/_ chars
after $. Add handling for special variable characters (#, ?, $, !, @, *, -)
so they resolve correctly inside (( )) arithmetic context.

Closes #876
@chaliy chaliy merged commit b2e6d88 into main Mar 28, 2026
23 checks passed
@chaliy chaliy deleted the fix/issue-876-special-vars-arithmetic branch March 28, 2026 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Special variables ($#, $?, $$) not expanded inside (( )) arithmetic context

1 participant