Skip to content

Can we get a better Shell for Windows? #454

Closed

Description

@PierrunoYT

Problem

Can we get a better Shell for Windows?

Image Image

Requested behavior

The Agent should be able to run shell commands fine on Windows

Why it belongs in Zero

Because Zero uses somekind of shell which is not reliable

Alternatives or workarounds considered

No response

Examples, screenshots, or prior discussion

No response

Activity

  1. added
    enhancement
    on Jul 3, 2026
  2. PierrunoYT commented on Jul 3, 2026

    @PierrunoYT
    ContributorAuthor

    Dug into the source to see what's actually happening here.

    Root cause: on Windows the bash tool always shells out to bare cmd.exe /d /s /c "<command>" (internal/tools/bash.go) — there's no Git-Bash, WSL, or PowerShell path. Since commands are generated in POSIX-flavored syntax (&& chains, export, $(...), ~, piped utilities like grep/sed/head/awk), cmd.exe either can't parse them or silently mishandles them.

    Detection of these mismatches is also thin:

    • Pre-execution (detectShellCommandIssue in internal/tools/shell_runtime.go) only flags cd /... and ls patterns — nothing for export, $(...), quoting, or piped POSIX tools.
    • Post-execution (detectShellOutputIssue) only matches two exact English cmd.exe error strings, so it misses non-English locales and any silent misparse that doesn't error at all.

    There's also a separate, documented limitation: under the sandbox's restricted token, Schannel-backed TLS (e.g. curl.exe over HTTPS) fails with SEC_E_NO_CREDENTIALS (internal/sandbox/windows_command_runner_windows.go) — noted in-code as a known gap with no fix, just workarounds (degraded path or the web_fetch tool).

    The recent fix/windows-interactive-command-suggestions work (c82d4e3, 9723150) only reworded the block-message suggestions for interactive commands (e.g. suggesting type/tasklist instead of cat/ps aux) — it doesn't touch the underlying shell mismatch, so this issue is still open.

    Possible directions, roughly in order of effort:

    1. Broaden the pre/post-execution mismatch detection to catch more POSIX-isms and give better translation hints (low risk, doesn't change what shell runs).
    2. Add an opt-in PowerShell execution path (powershell.exe -NoProfile -Command) alongside cmd.exe — PowerShell has aliases (ls, cat, pwd) and richer piping, closer to POSIX semantics without a new dependency.
    3. Auto-detect and prefer Git-Bash (bash.exe) when present on PATH for genuinely bash-compatible semantics — bigger change touching the sandbox wrapping (BuildWindowsSandboxCommandArgs, COMSPEC env default).

    Happy to pick one of these up if there's a preference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions