Skip to content

fix(builtins): printf -v, readonly assignment, quoted $@ fields and */ globs like bash - #2633

Merged
chaliy merged 11 commits into
mainfrom
claude/project-thread-eafupr-bb-declare
Oct 8, 2026
Merged

chaliy merged 11 commits into
mainfrom
claude/project-thread-eafupr-bb-declare

Conversation

@chaliy

@chaliy chaliy commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

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

What changed

Closes 16 of the 17 skipped BashBox declare / just-bash-compat spec cases, plus printf invalid-number errors.

  • printf -v parses options like bash (-vNAME, repeated -v, --); a missing -v argument or format, a bad option or an invalid name fail with status 2 and the usage line.
  • printf -v assigns through the interpreter like read: declare -i targets evaluate, a[i] sets elements, locals stay local.
  • read, printf -v and getopts into a readonly variable fail with readonly variable, status 1 (silently succeeded before).
  • Quoted $@ inside a larger word gives one field per element ("x$@y", x"${a[@]}"y); ${1+"$@"} keeps the original fields.
  • A glob ending in / matches only directories (and symlinks to them) and keeps the slash.
  • cp -n no longer overwrites.
  • $'\xc3\xa9' decodes as UTF-8 text.
  • printf '%d' abc / 12abc print 0 / 12, report printf: abc: invalid number, exit 1.

Why

Bash-verified cases from the BashBox corpus import (#2585) that bashkit failed.

Before

$ set -- a b; printf "[%s]" "x$@y"; echo
[xa by]
$ mkdir d1 d2; touch f1; echo */
d1 d2 f1
$ readonly r; printf -v r %s a; echo $?
0
$ printf -vy %s a; echo $y
-vy
$ printf '%d\n' abc; echo rc=$?
0
rc=0

After

[xa][by]
d1/ d2/
bash: line 1: r: readonly variable
1
a
0
bash: line 1: printf: abc: invalid number
rc=1

Matches real bash (bash_comparison_tests pass).

Risk

Low to medium: printf option parsing and quoted-$@ field splitting are widely used; covered by existing and new spec cases plus real-bash differential tests. One case stays skipped (declare -p of $'\xff', L-STREAM-001).

Checklist

  • cargo fmt --check, clippy -D warnings
  • cargo test -p bashkit -p bashkit-cli --lib --bins --tests -- --include-ignored
  • Knowledge updated (foundations/builtins.md, operations/limitations.md, log.md)

Generated by Claude Code

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

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 9194ecd Commit Preview URL

Branch Preview URL
Oct 08 2026, 05:20 AM

@chaliy
chaliy merged commit b2c8312 into main Oct 8, 2026
46 checks passed
@chaliy
chaliy deleted the claude/project-thread-eafupr-bb-declare branch October 8, 2026 05:46
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