Skip to content

Comments

feat(interpreter): implement declare -l/-u case conversion attributes#256

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

feat(interpreter): implement declare -l/-u case conversion attributes#256
chaliy merged 1 commit intomainfrom
claude/bashkit-bash-compatibility-BsDKD

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Feb 24, 2026

Summary

  • Implement declare -l (lowercase) and declare -u (uppercase) variable attributes
  • Attribute persists across assignments, converting values on each set_variable() call
  • Store attributes as _LOWER_<name> / _UPPER_<name> marker variables (consistent with existing _READONLY_*, _NAMEREF_* patterns)

Changes

  • crates/bashkit/src/interpreter/mod.rs: Parse -l/-u flags, apply case conversion in declare and set_variable()
  • crates/bashkit/tests/spec_cases/bash/declare.test.sh: 7 new spec tests covering basic, subsequent assignment, mixed case, override, and function usage
  • specs/009-implementation-status.md: Update test counts (declare 16→23, Bash 893→900, Total 1311→1318)

Test plan

  • cargo test --all-features passes
  • cargo fmt --check clean
  • cargo clippy --all-targets --all-features -- -D warnings clean
  • All 7 new declare spec tests pass
  • Verified against real bash behavior

Add support for `declare -l` (lowercase) and `declare -u` (uppercase)
variable attributes. When set, all subsequent assignments to the variable
are automatically converted to the specified case.

Implementation:
- Parse `-l` and `-u` flags in `execute_declare_builtin`
- Store attributes as `_LOWER_<name>` / `_UPPER_<name>` marker variables
- Apply case conversion in `set_variable()` for subsequent assignments
- Setting one attribute clears the opposite (e.g., -u clears _LOWER_)

Features:
- `declare -l x=HELLO` → x=hello
- `declare -u x=hello` → x=HELLO
- Attribute persists: `declare -l x; x=WORLD` → x=world
- Works in functions: `declare -u result="$1"`

Tests: 7 new spec tests (declare.test.sh: 16 → 23)
@chaliy chaliy force-pushed the claude/bashkit-bash-compatibility-BsDKD branch from 3929985 to 40eabf3 Compare February 25, 2026 03:44
@chaliy chaliy merged commit 966071f into main Feb 25, 2026
16 checks passed
@chaliy chaliy deleted the claude/bashkit-bash-compatibility-BsDKD branch February 25, 2026 03:53
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