Skip to content

feat(bash): implement let builtin and fix declare -i arithmetic#250

Merged
chaliy merged 1 commit intomainfrom
claude/bashkit-bash-compatibility-BsDKD
Feb 24, 2026
Merged

feat(bash): implement let builtin and fix declare -i arithmetic#250
chaliy merged 1 commit intomainfrom
claude/bashkit-bash-compatibility-BsDKD

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Feb 24, 2026

Summary

  • Implement let builtin for evaluating arithmetic expressions with assignment side effects
  • Fix declare -i to use arithmetic evaluation instead of parse().unwrap_or(0), so declare -i x=5+3 correctly yields 8
  • Add 11 spec tests covering let (basic, multiple, exit codes, increment, compound assign, no-args) and declare -i (basic, expressions, variable refs, plain numbers)

Test plan

  • cargo test --all-features passes
  • cargo clippy clean
  • cargo fmt --check clean
  • Spec tests verify let assignment, exit codes, and declare -i arithmetic

…valuation

`let` builtin evaluates arithmetic expressions with assignment side effects
and returns exit code 1 when last expression is zero, 0 otherwise.

`declare -i` now uses `evaluate_arithmetic_with_assign` instead of plain
`parse().unwrap_or(0)`, so `declare -i x=5+3` correctly yields 8.

Adds 11 tests for `let` (basic, multiple, exit codes, increment, compound
assign, no-args) and `declare -i` (basic, expressions, variable refs).
@chaliy chaliy merged commit 4d7818c into main Feb 24, 2026
16 checks passed
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.

2 participants