Skip to content

Comments

fix(bash): negative array indexing ${arr[-1]}#243

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

fix(bash): negative array indexing ${arr[-1]}#243
chaliy merged 1 commit intomainfrom
claude/bashkit-bash-compatibility-BsDKD

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Feb 24, 2026

Summary

  • Fix ${arr[-1]} to return last element instead of first
  • Fix arr[-1]=val to assign to last element instead of first
  • Negative i64 indices are now resolved as array_length + index
  • 4 new test cases: last, second-to-last, first-via-negative, write-negative

Test plan

  • 4 new tests covering read and write with negative indices
  • cargo test --all-features passes
  • cargo clippy and cargo fmt clean

Convert negative i64 to correct usize by computing array_length +
negative_index, for both read (${arr[-1]}) and write (arr[-1]=val)
paths.

https://claude.ai/code/session_012rzB3FRw7yoQWCG1mxyW7J
@chaliy chaliy merged commit 97c5434 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