Skip to content

Replace split_whitespace with shlex for shell-aware argument parsing#17

Merged
aniongithub merged 1 commit into
mainfrom
fix/command-quoting
May 11, 2026
Merged

Replace split_whitespace with shlex for shell-aware argument parsing#17
aniongithub merged 1 commit into
mainfrom
fix/command-quoting

Conversation

@aniongithub
Copy link
Copy Markdown
Owner

Summary

Replaces naive split_whitespace() argument splitting with the shlex crate for proper shell-aware parsing across all tools. Also replaces shell-escape with shlex for quoting (one crate for both directions).

Fixes #10, fixes #15

Changes

devcontainer_exec — always wrap in sh -c

The agent passes commands exactly like it would on the host:

devcontainer_exec(workspace_folder: "/path", command: "cargo build")
devcontainer_exec(workspace_folder: "/path", command: "cd /foo && npm test")
devcontainer_exec(workspace_folder: "/path", command: "git commit -m \"my message\"")

We handle the hard bits — no need for the agent to split command/args or worry about quoting. This matches how devpod_ssh and codespaces_ssh already work.

5 other tools — shlex::split() for CLI flags

devcontainer_up, devcontainer_build, devpod_up, devpod_build, devpod_provider_add now use shlex::split() instead of split_whitespace() so quoted values in extra args are preserved.

file_opsshlex::try_quote() replaces shell_escape

Removes the shell-escape dependency. shlex handles 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.

- 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
@aniongithub aniongithub force-pushed the fix/command-quoting branch from 824d84c to da4fe59 Compare May 11, 2026 07:32
@aniongithub aniongithub merged commit 42cda32 into main May 11, 2026
1 check passed
@aniongithub aniongithub deleted the fix/command-quoting branch May 11, 2026 08:01
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.

Args split on whitespace breaks quoted arguments devcontainer_exec: command param treated as single executable, compound shell commands fail

1 participant