Replace split_whitespace with shlex for shell-aware argument parsing#17
Merged
Conversation
- Replace shell-escape with shlex crate for both quoting and splitting - devcontainer_exec: always wrap in sh -c so agents can pass commands naturally (e.g. "cargo build", "cd /foo && npm test") without worrying about argument splitting - 5 other tools: use shlex::split() for CLI flag args to properly handle quoted values - file_ops: use shlex::try_quote() instead of shell_escape::escape() - Update test assertion to be quoting-strategy agnostic Fixes #10, fixes #15
824d84c to
da4fe59
Compare
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.
Summary
Replaces naive
split_whitespace()argument splitting with theshlexcrate for proper shell-aware parsing across all tools. Also replacesshell-escapewithshlexfor quoting (one crate for both directions).Fixes #10, fixes #15
Changes
devcontainer_exec— always wrap insh -cThe agent passes commands exactly like it would on the host:
We handle the hard bits — no need for the agent to split command/args or worry about quoting. This matches how
devpod_sshandcodespaces_sshalready work.5 other tools —
shlex::split()for CLI flagsdevcontainer_up,devcontainer_build,devpod_up,devpod_build,devpod_provider_addnow useshlex::split()instead ofsplit_whitespace()so quoted values in extra args are preserved.file_ops—shlex::try_quote()replacesshell_escapeRemoves the
shell-escapedependency.shlexhandles both splitting and quoting.Why
The design goal is simplicity for the agent: pass a command string, we handle the rest. Imposing quoting/splitting rules on agents makes it harder for smaller models to work correctly.