fix: avoid word splitting by space for windows shell commands (#7781)#7810
Merged
DOsinga merged 1 commit intoblock:mainfrom Mar 11, 2026
Merged
fix: avoid word splitting by space for windows shell commands (#7781)#7810DOsinga merged 1 commit intoblock:mainfrom
DOsinga merged 1 commit intoblock:mainfrom
Conversation
…7781) The problem: when running shell-commands on Windows, Goose splits command to words by spaces and when passes every word as a separate argument to command interpreter (cmd.exe). For example, when model tries to call a command: `find /I "word1 word2" *.txt` this command passed to command interpreter as (each line is a separate argument): - `cmd.exe` - `/C` - `find` - `/I` - `"word1` - `word2"` - `*.txt` Command interpreter (cmd.exe) just passes discrete arguments as is to `find` program. So instead of one argument `find` program accepts a string which is split into two argument. This causes following errors. Generally, this bug prevents using Goose on Windows (majority of commmands issued by the model include double quotes). Due to this bug model cannot use PowerShell, cannot use quoted file names, etc... The root cause of the issue is with how command line is constructed: ```rust let mut command = tokio::process::Command::new("cmd"); command.arg("/C").arg(command_line); ``` Even though `command_line` is passed as a single argument, if it contains spaces and quotes, the way Windows processes command line arguments can still cause issues with quote parsing. Solution: here's a Windows-specific method in tokio:process::Command called `raw_arg`: > __raw_arg__ Available on Windows only. > Append literal text to the command line without any quoting or escaping. > This is useful for passing arguments to `cmd.exe /c`, which doesn't follow > `CommandLineToArgvW` escaping rules. Now command line arguments for example shown above looks as: - `cmd.exe` - `/C` - `find /I "word1 word2" *.txt` Issue fixed. Signed-off-by: Kirill Frolov <k.frolov@samsung.com>
DOsinga
approved these changes
Mar 11, 2026
Collaborator
|
thanks! |
lifeizhou-ap
added a commit
that referenced
this pull request
Mar 12, 2026
* main: (270 commits) test(acp): align provider and server test parity (#7822) fix(acp): register MCP extensions when resuming a session (#7806) fix(goose): load .gitignore in prompt_manager for hint file filtering (#7795) fix: remap max_completion_tokens to max_tokens for OpenAI-compatible providers (#7765) fix(openai): preserve Responses API tool call/output linkage (#7759) chore(deps): bump @hono/node-server from 1.19.9 to 1.19.11 in /evals/open-model-gym/mcp-harness (#7687) fix: return ContextLengthExceeded when prompt exceeds effective KV cache size (#7815) feat: MCP Roots support (#7790) fix(google): use `includeThoughts/part.thought` for thinking handling (#7593) refactor: simplify tokenizer initialization — remove unnecessary Result wrapper (#7744) Fix model selector showing wrong model in tabs (#7784) Stop collecting goosed stderr after startup (#7814) fix: avoid word splitting by space for windows shell commands (#7781) (#7810) Simplify and make it not break on linux (#7813) Add preferred microphone selection (#7805) Remove dependency on posthog-rs (#7811) feat: load hints in nested subdirs (#7772) feat(acp): add read tool and delegate filesystem I/O to ACP clients (#7668) Support secret interpolation in streamable HTTP extension URLs (#7782) More logging for command injection classifier model training (#7779) ...
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.
The problem: when running shell-commands on Windows, Goose splits command to words by spaces and when passes every word as a separate argument to command interpreter (cmd.exe).
For example, when model tries to call a command:
find /I "word1 word2" *.txtthis command passed to command interpreter as (each line is a separate argument):cmd.exe/Cfind/I"word1word2"*.txtCommand interpreter (cmd.exe) just passes discrete arguments as is to
findprogram. So instead of one argumentfindprogram accepts a string which is split into two argument. This causes following errors.Generally, this bug prevents using Goose on Windows (majority of commmands issued by the model include double quotes). Due to this bug model cannot use PowerShell, cannot use quoted file names, etc...
The root cause of the issue is with how command line is constructed:
Even though
command_lineis passed as a single argument, if it contains spaces and quotes, the way Windows processes command line arguments can still cause issues with quote parsing.Solution:
here's a Windows-specific method in tokio:process::Command called
raw_arg:Now command line arguments for example shown above looks as:
cmd.exe/Cfind /I "word1 word2" *.txtIssue fixed.
Summary
Type of Change
AI Assistance
Testing
Related Issues
Relates to #ISSUE_ID
Discussion: LINK (if any)
Screenshots/Demos (for UX changes)
Before:
After: