Repository navigation
fix(interpreter): field-split the command word so "$@" runs as a command - #2510
Merged
Merged
Conversation
`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
Deploying with
|
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Михайло · project thread
What changed
The command word now goes through the same field splitting as arguments.
"$@","${@}",$@,"${arr[@]}", unquoted$cmdand$(...)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, sog echo hilooked up a command literally namedecho hi.Before / After
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
Checklist
spec_cases/bash/command-word-expansion.test.sh, 15 cases; 11 fail on main)https://claude.ai/code/session_01TNq48wTz3pUYQGXQEXHnTN
Generated by Claude Code