Skip to content

fix(interpreter): field-split the command word so "$@" runs as a command - #2510

Merged
chaliy merged 1 commit into
mainfrom
claude/fix-dollar-at-command-jmx0un
Oct 6, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/fix-dollar-at-command-jmx0un

Conversation

@chaliy

@chaliy chaliy commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

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

What changed

The command word now goes through the same field splitting as arguments. "$@", "${@}", $@, "${arr[@]}", unquoted $cmd and $(...) used as the command expand to several words: the first is the command name, the rest become leading arguments. An expansion that yields no words ("$@" with no params, empty unquoted $x) runs no command and exits 0, unless a command substitution ran, matching bash. Pure literal command names keep the old fast path.

Why

Wrapper functions like g(){ "$@"; } are a common bash idiom and failed outright: the command word was expanded to one string, so g echo hi looked up a command literally named echo hi.

Before / After

$ bashkit -c 'g(){ "$@"; }; g echo hi'
before: bash: echo hi: command not found   (rc=127)
after:  hi

Differential run against real bash on "$@", "${@}", $@, "$@" x, array splat, $c, $(echo echo sub), empty "$@", empty $x, set -- "" a; "$@", "$x" empty, set -- "echo z"; "$@": identical stdout/stderr/status (apart from bashkit's existing "Did you mean" suggestion). Exit status after empty expansion also matches bash now (false; "$@"; echo $? gives 0, z=$(false) $x; echo $? gives 1).

Risk

  • Low
  • Only non-literal command words take the new path. Glob/brace expansion is still not applied to the command word (unchanged).

Checklist

  • Tests added or updated (spec_cases/bash/command-word-expansion.test.sh, 15 cases; 11 fail on main)
  • Backward compatibility considered

https://claude.ai/code/session_01TNq48wTz3pUYQGXQEXHnTN


Generated by Claude Code

`g(){ "$@"; }; g echo hi` failed with "echo hi: command not found":
the command name was expanded to a single string, so "$@", ${arr[@]},
unquoted $cmd and $(...) never split. Expand non-literal command words
via expand_word_to_fields; first field is the name, the rest are
prepended to args. An expansion yielding no fields runs no command and
exits 0 unless a command substitution ran, matching bash.

Claude-Session: https://claude.ai/code/session_01TNq48wTz3pUYQGXQEXHnTN
@chaliy chaliy self-assigned this Oct 6, 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 c40a714 Commit Preview URL

Branch Preview URL
Oct 06 2026, 06:49 PM

@chaliy
chaliy merged commit 8161651 into main Oct 6, 2026
44 checks passed
@chaliy
chaliy deleted the claude/fix-dollar-at-command-jmx0un branch October 6, 2026 19:05
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