Skip to content

fix(interpreter): expand array literals like command words - #2594

Merged
chaliy merged 2 commits into
mainfrom
claude/oracle-small-gaps
Oct 7, 2026
Merged

chaliy merged 2 commits into
mainfrom
claude/oracle-small-gaps

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

  • Array literals (arr=(...)) run brace expansion and pathname expansion on each word, the same as command arguments. nullglob is honored and quoted words stay literal.
  • [i]=value elements inside an array literal set that index (no splitting or globbing of the value), and later plain words continue from i+1.
  • command -v accepts several names, prints each one it finds, and exits 1 only when none was found.

Why

Debian-oracle gaps: scripts collecting files with files=(*.txt) got the literal pattern, and arr=([2]=x) stored the text [2]=x.

Before / After

Script Before After (matches bash)
touch a.txt b.txt; arr=(*.txt); echo ${#arr[@]} 1 (*.txt) 2
arr=(x{1,2}); echo ${arr[@]} x{1,2} x1 x2
shopt -s nullglob; arr=(*.zz); echo ${#arr[@]} 1 0
arr=([2]=x y); declare -p arr ([0]="[2]=x" [1]="y") ([2]="x" [3]="y")
command -v nope echo; echo $? 1, nothing printed echo, 0

New spec file array-literal-expansion.test.sh (7 cases), each verified against bash 5.2.

Risk

Low. Under failglob an unmatched array-literal pattern is stored as-is instead of aborting the assignment (WTF comment in code). declare -a d=(...) still goes through the declare builtin path and is not changed here. Stack check depth_50_is_bounded passes at 2.01 MB.

Checklist

  • Failing spec first, verified against real bash
  • cargo test -p bashkit --lib, --test integration, bash_comparison
  • cargo clippy --all-targets -D warnings, cargo fmt --check
  • knowledge/log.md updated

https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA


Generated by Claude Code

@chaliy chaliy self-assigned this Oct 7, 2026
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 82e971b Commit Preview URL

Branch Preview URL
Oct 07 2026, 08:45 PM

chaliy added 2 commits October 7, 2026 20:44
Array literal words now get brace and pathname expansion (nullglob honored,
quoted words literal), and [i]=value elements set that index. command -v
accepts several names and succeeds when any is found.

Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
The per-word brace, glob and [i]=v handling grew the simple-command
future and overflowed the two-MiB recursion check under coverage.

Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
@chaliy
chaliy force-pushed the claude/oracle-small-gaps branch from fdfcd76 to 82e971b Compare October 7, 2026 20:44
@chaliy
chaliy merged commit 2796d82 into main Oct 7, 2026
44 checks passed
@chaliy
chaliy deleted the claude/oracle-small-gaps branch October 7, 2026 21:03
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.

1 participant